Skip to content

Commit 477da16

Browse files
committed
8352638: Enhance code consistency: java.desktop/windows
Reviewed-by: prr
1 parent a4c5ed8 commit 477da16

File tree

109 files changed

+743
-200
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+743
-200
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
*
6363
* @author Igor Kushnirskiy
6464
*/
65-
class AnimationController implements ActionListener, PropertyChangeListener {
65+
final class AnimationController implements ActionListener, PropertyChangeListener {
6666

6767
private static final boolean VISTA_ANIMATION_DISABLED =
6868
Boolean.getBoolean("swing.disablevistaanimation");
@@ -253,13 +253,15 @@ static void paintSkin(JComponent component, Skin skin,
253253
}
254254
}
255255

256+
@Override
256257
public synchronized void propertyChange(PropertyChangeEvent e) {
257258
if ("lookAndFeel" == e.getPropertyName()
258259
&& ! (e.getNewValue() instanceof WindowsLookAndFeel) ) {
259260
dispose();
260261
}
261262
}
262263

264+
@Override
263265
public synchronized void actionPerformed(ActionEvent e) {
264266
java.util.List<JComponent> componentsToRemove = null;
265267
java.util.List<Part> partsToRemove = null;
@@ -319,7 +321,7 @@ private synchronized void dispose() {
319321
}
320322
}
321323

322-
private static class AnimationState {
324+
private static final class AnimationState {
323325
private final State startState;
324326

325327
//animation duration in nanoseconds
@@ -407,7 +409,7 @@ boolean isDone() {
407409
}
408410
}
409411

410-
private static class PartUIClientPropertyKey
412+
private static final class PartUIClientPropertyKey
411413
implements UIClientPropertyKey {
412414

413415
private static final Map<Part, PartUIClientPropertyKey> map =
@@ -426,6 +428,7 @@ static synchronized PartUIClientPropertyKey getKey(Part part) {
426428
private PartUIClientPropertyKey(Part part) {
427429
this.part = part;
428430
}
431+
@Override
429432
public String toString() {
430433
return part.toString();
431434
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ public String getControlName(Component component) {
221221
return str + control.toString();
222222
}
223223

224+
@Override
224225
public String toString() {
225226
return control.toString()+"."+name();
226227
}
@@ -531,6 +532,7 @@ public int getValue() {
531532
return value;
532533
}
533534

535+
@Override
534536
public String toString() {
535537
return name()+"["+type.getName()+"] = "+value;
536538
}
@@ -559,6 +561,7 @@ private TypeEnum(Prop prop, String enumName, int value) {
559561
private final String enumName;
560562
private final int value;
561563

564+
@Override
562565
public String toString() {
563566
return prop+"="+enumName+"="+value;
564567
}

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
* @author Rich Schiavi
4444
*/
4545

46-
public class WindowsBorders {
46+
public final class WindowsBorders {
4747

4848
/**
4949
* Returns a border instance for a Windows Progress Bar
@@ -115,7 +115,7 @@ public static Border getInternalFrameBorder() {
115115
}
116116

117117
@SuppressWarnings("serial") // Superclass is not serializable across versions
118-
public static class ProgressBarBorder extends AbstractBorder implements UIResource {
118+
public static final class ProgressBarBorder extends AbstractBorder implements UIResource {
119119
protected Color shadow;
120120
protected Color highlight;
121121

@@ -124,6 +124,7 @@ public ProgressBarBorder(Color shadow, Color highlight) {
124124
this.shadow = shadow;
125125
}
126126

127+
@Override
127128
public void paintBorder(Component c, Graphics g, int x, int y,
128129
int width, int height) {
129130
g.setColor(shadow);
@@ -134,6 +135,7 @@ public void paintBorder(Component c, Graphics g, int x, int y,
134135
g.drawLine(width-1,y, width-1,height-1); // draw right
135136
}
136137

138+
@Override
137139
public Insets getBorderInsets(Component c, Insets insets) {
138140
insets.set(1,1,1,1);
139141
return insets;
@@ -146,7 +148,7 @@ public Insets getBorderInsets(Component c, Insets insets) {
146148
* @since 1.4
147149
*/
148150
@SuppressWarnings("serial") // Superclass is not serializable across versions
149-
public static class ToolBarBorder extends AbstractBorder implements UIResource, SwingConstants {
151+
public static final class ToolBarBorder extends AbstractBorder implements UIResource, SwingConstants {
150152
protected Color shadow;
151153
protected Color highlight;
152154

@@ -155,6 +157,7 @@ public ToolBarBorder(Color shadow, Color highlight) {
155157
this.shadow = shadow;
156158
}
157159

160+
@Override
158161
public void paintBorder(Component c, Graphics g, int x, int y,
159162
int width, int height) {
160163
if (!(c instanceof JToolBar)) {
@@ -224,6 +227,7 @@ public void paintBorder(Component c, Graphics g, int x, int y,
224227
g.translate(-x, -y);
225228
}
226229

230+
@Override
227231
public Insets getBorderInsets(Component c, Insets insets) {
228232
insets.set(1,1,1,1);
229233
if (!(c instanceof JToolBar)) {
@@ -259,6 +263,7 @@ public DashedBorder(Color color, int thickness) {
259263
super(color, thickness);
260264
}
261265

266+
@Override
262267
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
263268
Color oldColor = g.getColor();
264269
int i;
@@ -276,14 +281,15 @@ public void paintBorder(Component c, Graphics g, int x, int y, int width, int he
276281
* of the component's background color.
277282
*/
278283
@SuppressWarnings("serial") // Superclass is not serializable across versions
279-
static class ComplementDashedBorder extends LineBorder implements UIResource {
284+
static final class ComplementDashedBorder extends LineBorder implements UIResource {
280285
private Color origColor;
281286
private Color paintColor;
282287

283288
public ComplementDashedBorder() {
284289
super(null);
285290
}
286291

292+
@Override
287293
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
288294
Color color = c.getBackground();
289295

@@ -302,7 +308,7 @@ public void paintBorder(Component c, Graphics g, int x, int y, int width, int he
302308
* @since 1.4
303309
*/
304310
@SuppressWarnings("serial") // Superclass is not serializable across versions
305-
public static class InternalFrameLineBorder extends LineBorder implements
311+
public static final class InternalFrameLineBorder extends LineBorder implements
306312
UIResource {
307313
protected Color activeColor;
308314
protected Color inactiveColor;
@@ -315,6 +321,7 @@ public InternalFrameLineBorder(Color activeBorderColor,
315321
inactiveColor = inactiveBorderColor;
316322
}
317323

324+
@Override
318325
public void paintBorder(Component c, Graphics g, int x, int y,
319326
int width, int height) {
320327

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
*
5959
* @author Jeff Dinkins
6060
*/
61-
public class WindowsButtonUI extends BasicButtonUI
61+
public final class WindowsButtonUI extends BasicButtonUI
6262
{
6363
protected int dashedRectGapX;
6464
protected int dashedRectGapY;
@@ -89,6 +89,7 @@ public static ComponentUI createUI(JComponent c) {
8989
// ********************************
9090
// Defaults
9191
// ********************************
92+
@Override
9293
protected void installDefaults(AbstractButton b) {
9394
super.installDefaults(b);
9495
if(!defaults_initialized) {
@@ -108,6 +109,7 @@ protected void installDefaults(AbstractButton b) {
108109
}
109110
}
110111

112+
@Override
111113
protected void uninstallDefaults(AbstractButton b) {
112114
super.uninstallDefaults(b);
113115
defaults_initialized = false;
@@ -124,10 +126,12 @@ protected Color getFocusColor() {
124126
/**
125127
* Overridden method to render the text without the mnemonic
126128
*/
129+
@Override
127130
protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) {
128131
WindowsGraphicsUtils.paintText(g, b, textRect, text, getTextShiftOffset());
129132
}
130133

134+
@Override
131135
protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect){
132136

133137
// focus painted same color as text on Basic??
@@ -138,13 +142,15 @@ protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rect
138142
width - dashedRectGapWidth, height - dashedRectGapHeight);
139143
}
140144

145+
@Override
141146
protected void paintButtonPressed(Graphics g, AbstractButton b){
142147
setTextShiftOffset();
143148
}
144149

145150
// ********************************
146151
// Layout Methods
147152
// ********************************
153+
@Override
148154
public Dimension getPreferredSize(JComponent c) {
149155
Dimension d = super.getPreferredSize(c);
150156

@@ -167,6 +173,7 @@ public Dimension getPreferredSize(JComponent c) {
167173
*/
168174
private Rectangle viewRect = new Rectangle();
169175

176+
@Override
170177
public void paint(Graphics g, JComponent c) {
171178
if (XPStyle.getXP() != null) {
172179
WindowsButtonUI.paintXPButtonBackground(g, c);

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@
4141
/**
4242
* Windows check box menu item.
4343
*/
44-
public class WindowsCheckBoxMenuItemUI extends BasicCheckBoxMenuItemUI {
44+
public final class WindowsCheckBoxMenuItemUI extends BasicCheckBoxMenuItemUI {
4545

4646
final WindowsMenuItemUIAccessor accessor =
4747
new WindowsMenuItemUIAccessor() {
4848

49+
@Override
4950
public JMenuItem getMenuItem() {
5051
return menuItem;
5152
}
@@ -54,6 +55,7 @@ public State getState(JMenuItem menuItem) {
5455
return WindowsMenuItemUI.getState(this, menuItem);
5556
}
5657

58+
@Override
5759
public Part getPart(JMenuItem menuItem) {
5860
return WindowsMenuItemUI.getPart(this, menuItem);
5961
}
@@ -80,6 +82,7 @@ protected void paintBackground(Graphics g, JMenuItem menuItem,
8082
* @param text String to render
8183
* @since 1.4
8284
*/
85+
@Override
8386
protected void paintText(Graphics g, JMenuItem menuItem,
8487
Rectangle textRect, String text) {
8588
if (WindowsMenuItemUI.isVistaPainting()) {

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
* @author Jeff Dinkins
3939
*/
40-
public class WindowsCheckBoxUI extends WindowsRadioButtonUI
40+
public final class WindowsCheckBoxUI extends WindowsRadioButtonUI
4141
{
4242
// NOTE: WindowsCheckBoxUI inherits from WindowsRadioButtonUI instead
4343
// of BasicCheckBoxUI because we want to pick up all the
@@ -64,13 +64,15 @@ public static ComponentUI createUI(JComponent c) {
6464
}
6565

6666

67+
@Override
6768
public String getPropertyPrefix() {
6869
return propertyPrefix;
6970
}
7071

7172
// ********************************
7273
// Defaults
7374
// ********************************
75+
@Override
7476
public void installDefaults(AbstractButton b) {
7577
super.installDefaults(b);
7678
if(!defaults_initialized) {
@@ -79,6 +81,7 @@ public void installDefaults(AbstractButton b) {
7981
}
8082
}
8183

84+
@Override
8285
public void uninstallDefaults(AbstractButton b) {
8386
super.uninstallDefaults(b);
8487
defaults_initialized = false;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
* @since 1.5
3232
*/
3333
@SuppressWarnings("serial") // Superclass is not serializable across versions
34-
public class WindowsClassicLookAndFeel extends WindowsLookAndFeel {
34+
public final class WindowsClassicLookAndFeel extends WindowsLookAndFeel {
35+
@Override
3536
public String getName() {
3637
return "Windows Classic";
3738
}

0 commit comments

Comments
 (0)