< prev index next >
src/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java
Print this page
rev 1580 : 6727661: Code improvement and warnings removing from the swing/plaf packages
Summary: Removed unnecessary castings and other warnings
Reviewed-by: alexp
Contributed-by: Florian Brunner <fbrunnerlist@gmx.ch>
@@ -104,11 +104,11 @@
/**
* Map of defaults table entries. This is populated via the load
* method.
*/
- private Map defaultsMap;
+ private Map<String, Object> defaultsMap;
private Handler _handler;
static ComponentUI getSelectedUI() {
return (ComponentUI) AppContext.getAppContext().get(SELECTED_UI_KEY);
@@ -324,12 +324,12 @@
}
else if (c instanceof Container) {
children = ((Container)c).getComponents();
}
if (children != null) {
- for(int i = 0; i < children.length; i++) {
- updateStyles(children[i]);
+ for (Component child : children) {
+ updateStyles(child);
}
}
}
/**
@@ -597,11 +597,11 @@
throw new IllegalArgumentException(
"You must supply a valid resource base Class");
}
if (defaultsMap == null) {
- defaultsMap = new HashMap();
+ defaultsMap = new HashMap<String, Object>();
}
new SynthParser().parse(input, (DefaultSynthStyleFactory) factory,
null, resourceBase, defaultsMap);
}
@@ -627,11 +627,11 @@
throw new IllegalArgumentException(
"You must supply a valid Synth set URL");
}
if (defaultsMap == null) {
- defaultsMap = new HashMap();
+ defaultsMap = new HashMap<String, Object>();
}
InputStream input = url.openStream();
new SynthParser().parse(input, (DefaultSynthStyleFactory) factory,
url, null, defaultsMap);
@@ -803,11 +803,11 @@
*
* @return the text antialiasing information associated to the desktop
*/
private static Object getAATextInfo() {
String language = Locale.getDefault().getLanguage();
- String desktop = (String)
+ String desktop =
AccessController.doPrivileged(new GetPropertyAction("sun.desktop"));
boolean isCjkLocale = (Locale.CHINESE.getLanguage().equals(language) ||
Locale.JAPANESE.getLanguage().equals(language) ||
Locale.KOREAN.getLanguage().equals(language));
@@ -818,21 +818,21 @@
Object aaTextInfo = SwingUtilities2.AATextInfo.getAATextInfo(setAA);
return aaTextInfo;
}
- private static ReferenceQueue queue = new ReferenceQueue();
+ private static ReferenceQueue<LookAndFeel> queue = new ReferenceQueue<LookAndFeel>();
private static void flushUnreferenced() {
AATextListener aatl;
while ((aatl = (AATextListener) queue.poll()) != null) {
aatl.dispose();
}
}
private static class AATextListener
- extends WeakReference implements PropertyChangeListener {
+ extends WeakReference<LookAndFeel> implements PropertyChangeListener {
private String key = SunToolkit.DESKTOPFONTHINTS;
AATextListener(LookAndFeel laf) {
super(laf, queue);
Toolkit tk = Toolkit.getDefaultToolkit();
@@ -845,11 +845,11 @@
if (defaults.getBoolean("Synth.doNotSetTextAA")) {
dispose();
return;
}
- LookAndFeel laf = (LookAndFeel) get();
+ LookAndFeel laf = get();
if (laf == null || laf != UIManager.getLookAndFeel()) {
dispose();
return;
}
@@ -868,22 +868,22 @@
* Updates the UI of the passed in window and all its children.
*/
private static void updateWindowUI(Window window) {
updateStyles(window);
Window ownedWins[] = window.getOwnedWindows();
- for (int i = 0; i < ownedWins.length; i++) {
- updateWindowUI(ownedWins[i]);
+ for (Window w : ownedWins) {
+ updateWindowUI(w);
}
}
/**
* Updates the UIs of all the known Frames.
*/
private static void updateAllUIs() {
Frame appFrames[] = Frame.getFrames();
- for (int i = 0; i < appFrames.length; i++) {
- updateWindowUI(appFrames[i]);
+ for (Frame frame : appFrames) {
+ updateWindowUI(frame);
}
}
/**
* Indicates if an updateUI call is pending.
@@ -944,11 +944,11 @@
else if ("managingFocus" == propertyName) {
// De-register listener on old keyboard focus manager and
// register it on the new one.
KeyboardFocusManager manager =
(KeyboardFocusManager)evt.getSource();
- if (((Boolean)newValue).equals(Boolean.FALSE)) {
+ if (newValue.equals(Boolean.FALSE)) {
manager.removePropertyChangeListener(_handler);
}
else {
manager.addPropertyChangeListener(_handler);
}
< prev index next >