Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBorder.java
41154 views
1
/*
2
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package com.apple.laf;
27
28
import java.awt.*;
29
30
import javax.swing.*;
31
import javax.swing.border.Border;
32
import javax.swing.plaf.UIResource;
33
34
public class AquaMenuBorder implements Border, UIResource {
35
public AquaMenuBorder() { }
36
37
/**
38
* Paints the border for the specified component with the specified
39
* position and size.
40
* @param c the component for which this border is being painted
41
* @param g the paint graphics
42
* @param x the x position of the painted border
43
* @param y the y position of the painted border
44
* @param width the width of the painted border
45
* @param height the height of the painted border
46
*/
47
public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) {
48
// for now we don't paint a border. We let the button paint it since there
49
// needs to be a strict ordering for aqua components.
50
//paintButton(c, g, x, y, width, height);
51
//if (c instanceof JPopupMenu) {
52
//g.setColor(Color.red);
53
//g.drawRect(x,y, width-1, height-1);
54
//}
55
}
56
57
/**
58
* Returns whether or not the border is opaque. If the border
59
* is opaque, it is responsible for filling in it's own
60
* background when painting.
61
*/
62
public boolean isBorderOpaque() {
63
return false;
64
}
65
66
protected static Insets getItemInsets() {
67
return new Insets(1, 5, 1, 5);
68
}
69
70
protected static Insets getEmptyInsets() {
71
return new Insets(0, 0, 0, 0);
72
}
73
74
protected static Insets getPopupInsets() {
75
return new Insets(4, 0, 4, 0);
76
}
77
78
/**
79
* Returns the insets of the border.
80
* @param c the component for which this border insets value applies
81
*/
82
public Insets getBorderInsets(final Component c) {
83
if (!(c instanceof JPopupMenu)) {
84
return getItemInsets();
85
}
86
87
// for more info on this issue, see AquaComboBoxPopup.updateContents()
88
final JPopupMenu menu = (JPopupMenu)c;
89
final int nChildren = menu.getComponentCount();
90
if (nChildren > 0) {
91
final Component firstChild = menu.getComponent(0);
92
if (firstChild instanceof Box.Filler) return getEmptyInsets();
93
if (firstChild instanceof JScrollPane) return getEmptyInsets();
94
}
95
96
// just need top and bottom, and not right and left.
97
// but only for non-list popups.
98
return getPopupInsets();
99
}
100
}
101
102