Skip to content

Commit bd42e2c

Browse files
author
duke
committed
Backport 3468c6e5ef7e7592cf9484736ce333fbe0eaf34d
1 parent dea855e commit bd42e2c

File tree

6 files changed

+28
-64
lines changed

6 files changed

+28
-64
lines changed

src/java.desktop/share/classes/com/sun/java/swing/SwingUtilities3.java

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ public class SwingUtilities3 {
7272
private static final Object DELEGATE_REPAINT_MANAGER_KEY =
7373
new StringBuilder("DelegateRepaintManagerKey");
7474

75-
private static Color disabledForeground;
76-
private static Color acceleratorSelectionForeground;
77-
private static Color acceleratorForeground;
78-
7975
/**
8076
* Registers delegate RepaintManager for {@code JComponent}.
8177
*/
@@ -210,7 +206,10 @@ public static void paintIcon(Graphics g, MenuItemLayoutHelper lh,
210206

211207

212208
public static void paintAccText(Graphics g, MenuItemLayoutHelper lh,
213-
MenuItemLayoutHelper.LayoutResult lr) {
209+
MenuItemLayoutHelper.LayoutResult lr,
210+
Color disabledForeground,
211+
Color acceleratorSelectionForeground,
212+
Color acceleratorForeground) {
214213
if (!lh.getAccText().isEmpty()) {
215214
ButtonModel model = lh.getMenuItem().getModel();
216215
g.setFont(lh.getAccFontMetrics().getFont());
@@ -249,18 +248,6 @@ public static void paintAccText(Graphics g, MenuItemLayoutHelper lh,
249248
}
250249
}
251250

252-
public static void setDisabledForeground(Color disabledFg) {
253-
disabledForeground = disabledFg;
254-
}
255-
256-
public static void setAcceleratorSelectionForeground(Color acceleratorSelectionFg) {
257-
acceleratorSelectionForeground = acceleratorSelectionFg;
258-
}
259-
260-
public static void setAcceleratorForeground(Color acceleratorFg) {
261-
acceleratorForeground = acceleratorFg;
262-
}
263-
264251
public static void paintArrowIcon(Graphics g, MenuItemLayoutHelper lh,
265252
MenuItemLayoutHelper.LayoutResult lr,
266253
Color foreground) {

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -716,11 +716,10 @@ private void paintCheckIcon(Graphics g, MenuItemLayoutHelper lh,
716716

717717
private void paintAccText(Graphics g, MenuItemLayoutHelper lh,
718718
MenuItemLayoutHelper.LayoutResult lr) {
719-
SwingUtilities3.setDisabledForeground(disabledForeground);
720-
SwingUtilities3.setAcceleratorSelectionForeground(
721-
acceleratorSelectionForeground);
722-
SwingUtilities3.setAcceleratorForeground(acceleratorForeground);
723-
SwingUtilities3.paintAccText(g, lh, lr);
719+
SwingUtilities3.paintAccText(g, lh, lr,
720+
disabledForeground,
721+
acceleratorSelectionForeground,
722+
acceleratorForeground);
724723
}
725724

726725
private void paintText(Graphics g, MenuItemLayoutHelper lh,

src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxMenuItemUI.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ protected void paintMenuItem(Graphics g, JComponent c,
8282
int defaultTextIconGap) {
8383
if (WindowsMenuItemUI.isVistaPainting()) {
8484
WindowsMenuItemUI.paintMenuItem(accessor, g, c, checkIcon,
85-
arrowIcon, background, foreground, defaultTextIconGap,
85+
arrowIcon, background, foreground,
86+
disabledForeground, acceleratorSelectionForeground,
87+
acceleratorForeground, defaultTextIconGap,
8688
menuItem, getPropertyPrefix());
8789
return;
8890
}

src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ public class WindowsMenuItemUI extends BasicMenuItemUI {
6666
* The instance of {@code PropertyChangeListener}.
6767
*/
6868
private PropertyChangeListener changeListener;
69-
private static Color disabledForeground;
70-
private static Color acceleratorSelectionForeground;
71-
private static Color acceleratorForeground;
7269

7370
final WindowsMenuItemUIAccessor accessor =
7471
new WindowsMenuItemUIAccessor() {
@@ -164,44 +161,15 @@ protected void uninstallListeners() {
164161
changeListener = null;
165162
}
166163

167-
private static void applyInsets(Rectangle rect, Insets insets) {
168-
SwingUtilities3.applyInsets(rect, insets);
169-
}
170-
171-
private static void paintCheckIcon(Graphics g, MenuItemLayoutHelper lh,
172-
MenuItemLayoutHelper.LayoutResult lr,
173-
Color holdc, Color foreground) {
174-
SwingUtilities3.paintCheckIcon(g, lh, lr, holdc, foreground);
175-
}
176-
177-
private static void paintIcon(Graphics g, MenuItemLayoutHelper lh,
178-
MenuItemLayoutHelper.LayoutResult lr, Color holdc) {
179-
SwingUtilities3.paintIcon(g, lh, lr, holdc);
180-
}
181-
182-
private static void paintAccText(Graphics g, MenuItemLayoutHelper lh,
183-
MenuItemLayoutHelper.LayoutResult lr) {
184-
SwingUtilities3.setDisabledForeground(disabledForeground);
185-
SwingUtilities3.setAcceleratorSelectionForeground(
186-
acceleratorSelectionForeground);
187-
SwingUtilities3.setAcceleratorForeground(acceleratorForeground);
188-
SwingUtilities3.paintAccText(g, lh, lr);
189-
}
190-
191-
private static void paintArrowIcon(Graphics g, MenuItemLayoutHelper lh,
192-
MenuItemLayoutHelper.LayoutResult lr,
193-
Color foreground) {
194-
SwingUtilities3.paintArrowIcon(g, lh, lr, foreground);
195-
}
196-
197164
protected void paintMenuItem(Graphics g, JComponent c,
198165
Icon checkIcon, Icon arrowIcon,
199166
Color background, Color foreground,
200167
int defaultTextIconGap) {
201168
if (WindowsMenuItemUI.isVistaPainting()) {
202169
WindowsMenuItemUI.paintMenuItem(accessor, g, c, checkIcon,
203170
arrowIcon, background, foreground,
204-
defaultTextIconGap, menuItem,
171+
disabledForeground, acceleratorSelectionForeground,
172+
acceleratorForeground, defaultTextIconGap, menuItem,
205173
getPropertyPrefix());
206174
return;
207175
}
@@ -212,6 +180,9 @@ protected void paintMenuItem(Graphics g, JComponent c,
212180
static void paintMenuItem(WindowsMenuItemUIAccessor accessor, Graphics g,
213181
JComponent c, Icon checkIcon, Icon arrowIcon,
214182
Color background, Color foreground,
183+
Color disabledForeground,
184+
Color acceleratorSelectionForeground,
185+
Color acceleratorForeground,
215186
int defaultTextIconGap, JMenuItem menuItem, String prefix) {
216187
// Save original graphics font and color
217188
Font holdf = g.getFont();
@@ -221,7 +192,7 @@ static void paintMenuItem(WindowsMenuItemUIAccessor accessor, Graphics g,
221192
g.setFont(mi.getFont());
222193

223194
Rectangle viewRect = new Rectangle(0, 0, mi.getWidth(), mi.getHeight());
224-
applyInsets(viewRect, mi.getInsets());
195+
SwingUtilities3.applyInsets(viewRect, mi.getInsets());
225196

226197
String acceleratorDelimiter =
227198
UIManager.getString("MenuItem.acceleratorDelimiter");
@@ -239,8 +210,8 @@ static void paintMenuItem(WindowsMenuItemUIAccessor accessor, Graphics g,
239210
MenuItemLayoutHelper.LayoutResult lr = lh.layoutMenuItem();
240211

241212
paintBackground(accessor, g, mi, background);
242-
paintCheckIcon(g, lh, lr, holdc, foreground);
243-
paintIcon(g, lh, lr, holdc);
213+
SwingUtilities3.paintCheckIcon(g, lh, lr, holdc, foreground);
214+
SwingUtilities3.paintIcon(g, lh, lr, holdc);
244215

245216
if (lh.getCheckIcon() != null && lh.useCheckAndArrow()) {
246217
Rectangle rect = lr.getTextRect();
@@ -264,8 +235,10 @@ static void paintMenuItem(WindowsMenuItemUIAccessor accessor, Graphics g,
264235
rect.x += lh.getAfterCheckIconGap();
265236
lr.setAccRect(rect);
266237
}
267-
paintAccText(g, lh, lr);
268-
paintArrowIcon(g, lh, lr, foreground);
238+
SwingUtilities3.paintAccText(g, lh, lr, disabledForeground,
239+
acceleratorSelectionForeground,
240+
acceleratorForeground);
241+
SwingUtilities3.paintArrowIcon(g, lh, lr, foreground);
269242

270243
// Restore original graphics font and color
271244
g.setColor(holdc);

src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuUI.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ protected void paintMenuItem(Graphics g, JComponent c,
137137
if (WindowsMenuItemUI.isVistaPainting()) {
138138
WindowsMenuItemUI.paintMenuItem(accessor, g, c, checkIcon, arrowIcon,
139139
background, foreground,
140-
defaultTextIconGap, menuItem,
140+
disabledForeground, acceleratorSelectionForeground,
141+
acceleratorForeground, defaultTextIconGap, menuItem,
141142
getPropertyPrefix());
142143
return;
143144
}

src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonMenuItemUI.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ protected void paintMenuItem(Graphics g, JComponent c,
8282
int defaultTextIconGap) {
8383
if (WindowsMenuItemUI.isVistaPainting()) {
8484
WindowsMenuItemUI.paintMenuItem(accessor, g, c, checkIcon,
85-
arrowIcon, background, foreground, defaultTextIconGap,
85+
arrowIcon, background, foreground,
86+
disabledForeground, acceleratorSelectionForeground,
87+
acceleratorForeground, defaultTextIconGap,
8688
menuItem, getPropertyPrefix());
8789
return;
8890
}

0 commit comments

Comments
 (0)