You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/11/25 21:56:43 UTC
svn commit: r479197 [1/2] -
/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/
Author: ndbeyer
Date: Sat Nov 25 12:56:42 2006
New Revision: 479197
URL: http://svn.apache.org/viewvc?view=rev&rev=479197
Log:
Cleanup
* add missing annotations
* add serialVersionUID fields and comments
* format code
Modified:
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultSingleSelectionModel.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/FocusManager.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/GrayFilter.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/Icon.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ImageIcon.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/InputMap.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JApplet.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JButton.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JCheckBox.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JCheckBoxMenuItem.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JColorChooser.java
harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JComponent.java
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultSingleSelectionModel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultSingleSelectionModel.java?view=diff&rev=479197&r1=479196&r2=479197
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultSingleSelectionModel.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/DefaultSingleSelectionModel.java Sat Nov 25 12:56:42 2006
@@ -15,22 +15,29 @@
* limitations under the License.
*/
-/**
- * @author Anton Avtamonov
- * @version $Revision$
- */
-
package javax.swing;
import java.io.Serializable;
import java.util.EventListener;
-
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;
+/**
+ * <p>
+ * <i>DefaultSingleSelectionModel</i>
+ * </p>
+ * <h3>Implementation Notes:</h3>
+ * <ul>
+ * <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
+ * optimization, not as a guarantee of serialization compatibility.</li>
+ * </ul>
+ */
public class DefaultSingleSelectionModel implements Serializable, SingleSelectionModel {
+ private static final long serialVersionUID = -8733648221309386264L;
+
protected ChangeEvent changeEvent;
+
protected EventListenerList listenerList = new EventListenerList();
private int selectedIndex = -1;
@@ -40,7 +47,7 @@
fireStateChanged();
}
- public void setSelectedIndex(final int index) {
+ public void setSelectedIndex(int index) {
selectedIndex = index;
fireStateChanged();
}
@@ -53,20 +60,20 @@
return selectedIndex > -1;
}
- public void addChangeListener(final ChangeListener l) {
+ public void addChangeListener(ChangeListener l) {
listenerList.add(ChangeListener.class, l);
}
- public void removeChangeListener(final ChangeListener l) {
+ public void removeChangeListener(ChangeListener l) {
listenerList.remove(ChangeListener.class, l);
}
- public <T extends java.util.EventListener> T[] getListeners(final Class<T> listenerType) {
+ public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
return listenerList.getListeners(listenerType);
}
public ChangeListener[] getChangeListeners() {
- return (ChangeListener[])getListeners(ChangeListener.class);
+ return getListeners(ChangeListener.class);
}
protected void fireStateChanged() {
@@ -83,7 +90,6 @@
if (changeEvent == null) {
changeEvent = new ChangeEvent(this);
}
-
return changeEvent;
}
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/FocusManager.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/FocusManager.java?view=diff&rev=479197&r1=479196&r2=479197
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/FocusManager.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/FocusManager.java Sat Nov 25 12:56:42 2006
@@ -15,11 +15,6 @@
* limitations under the License.
*/
-/**
- * @author Anton Avtamonov
- * @version $Revision$
- */
-
package javax.swing;
import java.awt.DefaultFocusTraversalPolicy;
@@ -40,9 +35,8 @@
KeyboardFocusManager currentManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
if (currentManager instanceof FocusManager) {
return (FocusManager)currentManager;
- } else {
- return null;
}
+ return null;
}
public static void setCurrentManager(final FocusManager focusManager) throws SecurityException {
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/GrayFilter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/GrayFilter.java?view=diff&rev=479197&r1=479196&r2=479197
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/GrayFilter.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/GrayFilter.java Sat Nov 25 12:56:42 2006
@@ -29,17 +29,17 @@
import java.awt.image.RGBImageFilter;
public class GrayFilter extends RGBImageFilter {
- private final ColorTransformationStrategy strategy;
- private final float interval;
-
private static final float INTERVAL_BOUND = 1f / 3;
-
- public static Image createDisabledImage(final Image i) {
+
+ public static Image createDisabledImage(Image i) {
FilteredImageSource fis = new FilteredImageSource(i.getSource(), new GrayFilter(true, 50));
return Toolkit.getDefaultToolkit().createImage(fis);
}
+
+ private final ColorTransformationStrategy strategy;
+ private final float interval;
- public GrayFilter(final boolean bright, final int grayPercentage) {
+ public GrayFilter(boolean bright, int grayPercentage) {
if (grayPercentage < 0 || grayPercentage > 100) {
throw new IllegalArgumentException("Incorrect range for grayscale factor");
}
@@ -55,7 +55,8 @@
this.interval = INTERVAL_BOUND * (100 - grayPercentage) / 100f;
}
- public int filterRGB(final int x, final int y, final int rgb) {
+ @Override
+ public int filterRGB(int x, int y, int rgb) {
int alpha = (rgb >> 24) & 0xFF;
int r = (rgb >> 16) & 0xFF;
int g = (rgb >> 8) & 0xFF;
@@ -78,11 +79,11 @@
private class BrightingColorTransformationStrategy implements ColorTransformationStrategy {
private final float lowBound;
- public BrightingColorTransformationStrategy(final float lowBound) {
+ public BrightingColorTransformationStrategy(float lowBound) {
this.lowBound = lowBound;
}
- public int getRGB(final float brightness) {
+ public int getRGB(float brightness) {
float normalizedBrightness = lowBound + brightness * interval;
return Color.HSBtoRGB(0, 0, normalizedBrightness);
}
@@ -94,4 +95,3 @@
}
}
}
-
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/Icon.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/Icon.java?view=diff&rev=479197&r1=479196&r2=479197
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/Icon.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/Icon.java Sat Nov 25 12:56:42 2006
@@ -15,21 +15,15 @@
* limitations under the License.
*/
-/**
- * @author Sergey Burlak
- * @version $Revision$
- */
-
package javax.swing;
import java.awt.Component;
import java.awt.Graphics;
public interface Icon {
+ void paintIcon(Component c, Graphics g, int x, int y);
- public void paintIcon(final Component c, final Graphics g, final int x, final int y);
-
- public int getIconWidth();
+ int getIconWidth();
- public int getIconHeight();
+ int getIconHeight();
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ImageIcon.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ImageIcon.java?view=diff&rev=479197&r1=479196&r2=479197
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ImageIcon.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ImageIcon.java Sat Nov 25 12:56:42 2006
@@ -14,10 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/**
- * @author Alexander T. Simbirtsev
- * @version $Revision$
- */
+
package javax.swing;
import java.awt.Component;
@@ -31,78 +28,101 @@
import java.io.Serializable;
import java.net.URL;
import java.util.Locale;
-
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleIcon;
import javax.accessibility.AccessibleRole;
import javax.accessibility.AccessibleStateSet;
+import org.apache.harmony.luni.util.NotImplementedException;
+/**
+ * <p>
+ * <i>ImageIcon</i>
+ * </p>
+ * <h3>Implementation Notes:</h3>
+ * <ul>
+ * <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
+ * optimization, not as a guarantee of serialization compatibility.</li>
+ * </ul>
+ */
public class ImageIcon implements Icon, Serializable, Accessible {
+ private static final long serialVersionUID = -6101950798829449111L;
- //TODO: implement
- protected class AccessibleImageIcon extends AccessibleContext
- implements AccessibleIcon, Serializable {
+ // TODO: implement
+ protected class AccessibleImageIcon extends AccessibleContext implements AccessibleIcon,
+ Serializable {
+ private static final long serialVersionUID = -860693743697825660L;
- public Accessible getAccessibleChild(final int i) {
- return null;
+ @Override
+ public Accessible getAccessibleChild(int i) throws NotImplementedException {
+ throw new NotImplementedException();
}
- public int getAccessibleChildrenCount() {
- return 0;
+ @Override
+ public int getAccessibleChildrenCount() throws NotImplementedException {
+ throw new NotImplementedException();
}
- public int getAccessibleIndexInParent() {
- return 0;
+ @Override
+ public int getAccessibleIndexInParent() throws NotImplementedException {
+ throw new NotImplementedException();
}
+ @Override
public AccessibleRole getAccessibleRole() {
return AccessibleRole.ICON;
}
- public AccessibleStateSet getAccessibleStateSet() {
- return null;
+ @Override
+ public AccessibleStateSet getAccessibleStateSet() throws NotImplementedException {
+ throw new NotImplementedException();
}
- public Locale getLocale() throws IllegalComponentStateException {
- return null;
+ @Override
+ public Locale getLocale() throws IllegalComponentStateException,
+ NotImplementedException {
+ throw new NotImplementedException();
}
- public void setAccessibleIconDescription(final String description) {
+ public void setAccessibleIconDescription(String description)
+ throws NotImplementedException {
+ throw new NotImplementedException();
}
- public String getAccessibleIconDescription() {
- return getDescription();
+ public String getAccessibleIconDescription() throws NotImplementedException {
+ throw new NotImplementedException();
}
- public int getAccessibleIconWidth() {
- return 0;
+ public int getAccessibleIconWidth() throws NotImplementedException {
+ throw new NotImplementedException();
}
- public int getAccessibleIconHeight() {
- return 0;
+ public int getAccessibleIconHeight() throws NotImplementedException {
+ throw new NotImplementedException();
}
-
}
protected static final Component component;
+
protected static final MediaTracker tracker;
private ImageObserver observer;
+
private AccessibleContext accessibleContext;
+
private Image image;
+
private String description;
/**
- * unique id is to enable image loading tracking via MediaTracker
+ * Unique id is to enable image loading tracking via MediaTracker
*/
private final int id = getUniqueID();
/**
- * is used for generating unique ids for icons
+ * The last unique ID assigned.
*/
private static int lastAssignedID;
-
static {
component = new Panel();
tracker = new MediaTracker(component);
@@ -116,60 +136,60 @@
return lastAssignedID++;
}
- public ImageIcon(final URL url, final String description) {
+ public ImageIcon(URL url, String description) {
this(url);
this.description = description;
}
- public ImageIcon(final String fileName, final String description) {
+ public ImageIcon(String fileName, String description) {
this(fileName);
this.description = description;
}
- public ImageIcon(final Image image, final String description) {
+ public ImageIcon(Image image, String description) {
this(image);
this.description = description;
}
- public ImageIcon(final byte[] imageData, final String description) {
+ public ImageIcon(byte[] imageData, String description) {
this(imageData);
this.description = description;
}
- public ImageIcon(final URL url) {
+ public ImageIcon(URL url) {
image = Toolkit.getDefaultToolkit().createImage(url);
loadImage(image);
description = url.toString();
}
- public ImageIcon(final String fileName) {
+ public ImageIcon(String fileName) {
image = Toolkit.getDefaultToolkit().createImage(fileName);
loadImage(image);
description = fileName;
}
- public ImageIcon(final Image image) {
+ public ImageIcon(Image image) {
this.image = image;
loadImage(image);
Object comment = image.getProperty("comment", observer);
if (comment instanceof String) {
- description = (String)comment;
+ description = (String) comment;
}
}
- public ImageIcon(final byte[] imageData) {
+ public ImageIcon(byte[] imageData) {
image = Toolkit.getDefaultToolkit().createImage(imageData);
loadImage(image);
Object comment = image.getProperty("comment", observer);
if (comment instanceof String) {
- description = (String)comment;
+ description = (String) comment;
}
}
public ImageIcon() {
}
- public synchronized void paintIcon(final Component c, final Graphics g, final int x, final int y) {
+ public synchronized void paintIcon(Component c, Graphics g, int x, int y) {
g.drawImage(image, x, y, (observer != null) ? observer : c);
}
@@ -178,10 +198,11 @@
: accessibleContext;
}
- public void setDescription(final String description) {
+ public void setDescription(String description) {
this.description = description;
}
+ @Override
public String toString() {
return description != null ? description : super.toString();
}
@@ -190,7 +211,7 @@
return description;
}
- public void setImageObserver(final ImageObserver observer) {
+ public void setImageObserver(ImageObserver observer) {
this.observer = observer;
}
@@ -198,18 +219,19 @@
return observer;
}
- public void setImage(final Image newImage) {
+ public void setImage(Image newImage) {
tracker.removeImage(image);
image = newImage;
tracker.addImage(image, id);
}
- protected void loadImage(final Image image) {
+ protected void loadImage(Image image) {
tracker.addImage(image, id);
try {
tracker.waitForID(id);
} catch (InterruptedException e) {
- System.out.println(e);
+ // reset the interrupt state for the current thread
+ Thread.currentThread().interrupt();
}
}
@@ -229,4 +251,3 @@
return (image != null) ? image.getHeight(observer) : -1;
}
}
-
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/InputMap.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/InputMap.java?view=diff&rev=479197&r1=479196&r2=479197
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/InputMap.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/InputMap.java Sat Nov 25 12:56:42 2006
@@ -14,10 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/**
- * @author Alexander T. Simbirtsev
- * @version $Revision$
- */
+
package javax.swing;
import java.io.Serializable;
@@ -25,18 +22,30 @@
import java.util.HashMap;
import java.util.HashSet;
+/**
+ * <p>
+ * <i>InputMap</i>
+ * </p>
+ * <h3>Implementation Notes:</h3>
+ * <ul>
+ * <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
+ * optimization, not as a guarantee of serialization compatibility.</li>
+ * </ul>
+ */
public class InputMap implements Serializable {
+ private static final long serialVersionUID = -6824008057073482094L;
private InputMap parent;
- private HashMap table;
- public void put(final KeyStroke keyStroke, final Object key) {
+ private HashMap<KeyStroke, Object> table;
+
+ public void put(KeyStroke keyStroke, Object key) {
if (keyStroke == null) {
return;
}
if (key != null) {
if (table == null) {
- table = new HashMap();
+ table = new HashMap<KeyStroke, Object>();
}
table.put(keyStroke, key);
} else {
@@ -44,7 +53,7 @@
}
}
- public Object get(final KeyStroke keyStroke) {
+ public Object get(KeyStroke keyStroke) {
Object key = null;
if (table != null) {
key = table.get(keyStroke);
@@ -52,11 +61,10 @@
if (key == null && getParent() != null) {
key = getParent().get(keyStroke);
}
-
return key;
}
- public void remove(final KeyStroke keyStroke) {
+ public void remove(KeyStroke keyStroke) {
if (table != null) {
table.remove(keyStroke);
}
@@ -66,7 +74,7 @@
if (table == null) {
return new KeyStroke[0];
}
- return (KeyStroke[])table.keySet().toArray(new KeyStroke[table.size()]);
+ return table.keySet().toArray(new KeyStroke[table.size()]);
}
public KeyStroke[] allKeys() {
@@ -81,12 +89,12 @@
if (parentKeys.length == 0) {
return keys;
}
- HashSet keySet = new HashSet(Arrays.asList(keys));
+ HashSet<KeyStroke> keySet = new HashSet<KeyStroke>(Arrays.asList(keys));
keySet.addAll(Arrays.asList(parentKeys));
- return (KeyStroke[])keySet.toArray(new KeyStroke[keySet.size()]);
+ return keySet.toArray(new KeyStroke[keySet.size()]);
}
- public void setParent(final InputMap parent) {
+ public void setParent(InputMap parent) {
this.parent = parent;
}
@@ -103,5 +111,4 @@
public int size() {
return (table != null) ? table.size() : 0;
}
-
-}
\ No newline at end of file
+}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JApplet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JApplet.java?view=diff&rev=479197&r1=479196&r2=479197
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JApplet.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JApplet.java Sat Nov 25 12:56:42 2006
@@ -18,7 +18,6 @@
package javax.swing;
import java.applet.Applet;
-
import java.awt.AWTEvent;
import java.awt.BorderLayout;
import java.awt.Color;
@@ -28,58 +27,63 @@
import java.awt.HeadlessException;
import java.awt.KeyboardFocusManager;
import java.awt.LayoutManager;
-
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
+/**
+ * <p>
+ * <i>JApplet</i>
+ * </p>
+ * <h3>Implementation Notes:</h3>
+ * <ul>
+ * <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
+ * optimization, not as a guarantee of serialization compatibility.</li>
+ * </ul>
+ */
public class JApplet extends Applet implements Accessible, RootPaneContainer {
+ private static final long serialVersionUID = -8372957450536936161L;
+
protected JRootPane rootPane;
+
protected boolean rootPaneCheckingEnabled;
+
protected AccessibleContext accessibleContext;
public JApplet() throws HeadlessException {
setLayout(new BorderLayout());
-
setRootPaneCheckingEnabled(true);
-
setRootPane(createRootPane());
-
setLocale(JComponent.getDefaultLocale());
-
setBackground(Color.white);
-
// enable events
enableEvents(AWTEvent.KEY_EVENT_MASK);
-
setFocusTraversalPolicyProvider(true);
-
- setFocusTraversalPolicy(KeyboardFocusManager.
- getCurrentKeyboardFocusManager().
- getDefaultFocusTraversalPolicy());
+ setFocusTraversalPolicy(KeyboardFocusManager.getCurrentKeyboardFocusManager()
+ .getDefaultFocusTraversalPolicy());
}
protected class AccessibleJApplet extends AccessibleApplet {
+ private static final long serialVersionUID = -7345678942864978889L;
+
protected AccessibleJApplet() {
+ super();
}
}
- protected void addImpl(final Component comp, final Object constraints,
- final int index) {
+ @Override
+ protected void addImpl(Component comp, Object constraints, int index) {
if (isRootPaneCheckingEnabled()) {
getContentPane().add(comp, constraints, index);
return;
}
-
super.addImpl(comp, constraints, index);
}
- protected void setRootPane(final JRootPane root) {
+ protected void setRootPane(JRootPane root) {
if (rootPane != null) {
remove(rootPane);
}
-
rootPane = root;
-
if (root != null) {
super.addImpl(root, null, 0);
}
@@ -93,7 +97,7 @@
return new JRootPane();
}
- public void setJMenuBar(final JMenuBar menuBar) {
+ public void setJMenuBar(JMenuBar menuBar) {
getRootPane().setJMenuBar(menuBar);
}
@@ -101,7 +105,7 @@
return getRootPane().getJMenuBar();
}
- public void setLayeredPane(final JLayeredPane layeredPane) {
+ public void setLayeredPane(JLayeredPane layeredPane) {
getRootPane().setLayeredPane(layeredPane);
}
@@ -109,15 +113,16 @@
return getRootPane().getLayeredPane();
}
+ @Override
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJApplet();
}
-
return accessibleContext;
}
- public void setLayout(final LayoutManager layout) {
+ @Override
+ public void setLayout(LayoutManager layout) {
if (isRootPaneCheckingEnabled()) {
getContentPane().setLayout(layout);
} else {
@@ -131,11 +136,12 @@
*
* @param g - the graphics context to paint
*/
- public void update(final Graphics g) {
+ @Override
+ public void update(Graphics g) {
paint(g);
}
- public void setContentPane(final Container contentPane) {
+ public void setContentPane(Container contentPane) {
getRootPane().setContentPane(contentPane);
}
@@ -143,11 +149,12 @@
return getRootPane().getContentPane();
}
- public void setGlassPane(final Component glassPane) {
+ public void setGlassPane(Component glassPane) {
getRootPane().setGlassPane(glassPane);
}
- public void remove(final Component comp) {
+ @Override
+ public void remove(Component comp) {
if (comp == getRootPane()) {
// remove directly from JApplet
super.remove(comp);
@@ -160,7 +167,7 @@
return getRootPane().getGlassPane();
}
- protected void setRootPaneCheckingEnabled(final boolean enabled) {
+ protected void setRootPaneCheckingEnabled(boolean enabled) {
rootPaneCheckingEnabled = enabled;
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JButton.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JButton.java?view=diff&rev=479197&r1=479196&r2=479197
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JButton.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JButton.java Sat Nov 25 12:56:42 2006
@@ -14,47 +14,56 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/**
- * @author Alexander T. Simbirtsev
- * @version $Revision$
- */
+
package javax.swing;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
-
import org.apache.harmony.x.swing.StringConstants;
-
+/**
+ * <p>
+ * <i>JButton</i>
+ * </p>
+ * <h3>Implementation Notes:</h3>
+ * <ul>
+ * <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
+ * optimization, not as a guarantee of serialization compatibility.</li>
+ * </ul>
+ */
public class JButton extends AbstractButton implements Accessible {
+ private static final long serialVersionUID = 8822265937932828454L;
protected class AccessibleJButton extends AccessibleAbstractButton {
+ private static final long serialVersionUID = -1171440163825721899L;
+
+ @Override
public AccessibleRole getAccessibleRole() {
return AccessibleRole.PUSH_BUTTON;
}
- };
+ }
private boolean defaultCapable = true;
private static final String UI_CLASS_ID = "ButtonUI";
- public JButton(final String text, final Icon icon) {
+ public JButton(String text, Icon icon) {
setModel(new DefaultButtonModel());
init(text, icon);
}
- public JButton(final Icon icon) {
+ public JButton(Icon icon) {
this(null, icon);
}
- public JButton(final Action action) {
+ public JButton(Action action) {
setModel(new DefaultButtonModel());
setAction(action);
init(getText(), getIcon());
}
- public JButton(final String text) {
+ public JButton(String text) {
this(text, null);
}
@@ -62,19 +71,22 @@
this(null, null);
}
+ @Override
public AccessibleContext getAccessibleContext() {
return (accessibleContext == null) ? (accessibleContext = new AccessibleJButton())
: accessibleContext;
}
+ @Override
public String getUIClassID() {
return UI_CLASS_ID;
}
- public void setDefaultCapable(final boolean defaultCapable) {
+ public void setDefaultCapable(boolean defaultCapable) {
boolean oldValue = this.defaultCapable;
this.defaultCapable = defaultCapable;
- firePropertyChange(StringConstants.DEFAULT_CAPABLE_PROPERTY_CHANGED, oldValue, defaultCapable);
+ firePropertyChange(StringConstants.DEFAULT_CAPABLE_PROPERTY_CHANGED, oldValue,
+ defaultCapable);
}
public boolean isDefaultCapable() {
@@ -86,6 +98,7 @@
return isDefaultButton(rootPane);
}
+ @Override
public void removeNotify() {
final JRootPane rootPane = getRootPane();
if (isDefaultButton(rootPane)) {
@@ -94,9 +107,7 @@
super.removeNotify();
}
- private boolean isDefaultButton(final JRootPane rootPane) {
+ private boolean isDefaultButton(JRootPane rootPane) {
return (rootPane != null) && (rootPane.getDefaultButton() == this);
}
-
}
-
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JCheckBox.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JCheckBox.java?view=diff&rev=479197&r1=479196&r2=479197
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JCheckBox.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JCheckBox.java Sat Nov 25 12:56:42 2006
@@ -14,21 +14,33 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/**
- * @author Alexander T. Simbirtsev
- * @version $Revision$
- */
+
package javax.swing;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
+/**
+ * <p>
+ * <i>JCheckBox</i>
+ * </p>
+ * <h3>Implementation Notes:</h3>
+ * <ul>
+ * <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
+ * optimization, not as a guarantee of serialization compatibility.</li>
+ * </ul>
+ */
public class JCheckBox extends JToggleButton {
+ private static final long serialVersionUID = 2823978782065130270L;
+
protected class AccessibleJCheckBox extends AccessibleJToggleButton {
+ private static final long serialVersionUID = -7895379006459422318L;
+
+ @Override
public AccessibleRole getAccessibleRole() {
return AccessibleRole.CHECK_BOX;
}
- };
+ }
public static final String BORDER_PAINTED_FLAT_CHANGED_PROPERTY = "borderPaintedFlat";
@@ -40,51 +52,55 @@
super(null, null, false);
}
- public JCheckBox(final Action action) {
+ public JCheckBox(Action action) {
super(action);
}
- public JCheckBox(final Icon icon) {
+ public JCheckBox(Icon icon) {
super(null, icon, false);
}
- public JCheckBox(final Icon icon, final boolean selected) {
+ public JCheckBox(Icon icon, boolean selected) {
super(null, icon, selected);
}
- public JCheckBox(final String text) {
+ public JCheckBox(String text) {
super(text, null, false);
}
- public JCheckBox(final String text, final boolean selected) {
+ public JCheckBox(String text, boolean selected) {
super(text, null, selected);
}
- public JCheckBox(final String text, final Icon icon) {
+ public JCheckBox(String text, Icon icon) {
super(text, icon, false);
}
- public JCheckBox(final String text, final Icon icon, final boolean selected) {
+ public JCheckBox(String text, Icon icon, boolean selected) {
super(text, icon, selected);
}
- void configurePropertyFromAction(final Action action, final Object propertyName) {
+ @Override
+ void configurePropertyFromAction(Action action, Object propertyName) {
if (propertyName == null || propertyName.equals(Action.SMALL_ICON)) {
return;
}
super.configurePropertyFromAction(action, propertyName);
}
- protected void init(final String text, final Icon icon) {
+ @Override
+ protected void init(String text, Icon icon) {
setHorizontalAlignment(LEADING);
super.init(text, icon);
}
+ @Override
public AccessibleContext getAccessibleContext() {
return (accessibleContext == null) ? (accessibleContext = new AccessibleJCheckBox())
: accessibleContext;
}
+ @Override
public String getUIClassID() {
return UI_CLASS_ID;
}
@@ -93,14 +109,14 @@
return borderPaintedFlat;
}
- public void setBorderPaintedFlat(final boolean paintedFlat) {
+ public void setBorderPaintedFlat(boolean paintedFlat) {
boolean oldValue = borderPaintedFlat;
borderPaintedFlat = paintedFlat;
firePropertyChange(BORDER_PAINTED_FLAT_CHANGED_PROPERTY, oldValue, borderPaintedFlat);
}
+ @Override
Object getActionPropertiesFilter() {
return JRadioButton.NO_ICON_ACTION_PROPERTIES;
}
}
-
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JCheckBoxMenuItem.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JCheckBoxMenuItem.java?view=diff&rev=479197&r1=479196&r2=479197
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JCheckBoxMenuItem.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JCheckBoxMenuItem.java Sat Nov 25 12:56:42 2006
@@ -14,18 +14,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/**
-* @author Alexander T. Simbirtsev
-* @version $Revision$
-*/
+
package javax.swing;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
+/**
+ * <p>
+ * <i>JCheckBoxMenuItem</i>
+ * </p>
+ * <h3>Implementation Notes:</h3>
+ * <ul>
+ * <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
+ * optimization, not as a guarantee of serialization compatibility.</li>
+ * </ul>
+ */
public class JCheckBoxMenuItem extends JMenuItem {
+ private static final long serialVersionUID = 7596676985032928624L;
protected class AccessibleJCheckBoxMenuItem extends AccessibleJMenuItem {
+ private static final long serialVersionUID = -5343091705345502936L;
+
+ @Override
public AccessibleRole getAccessibleRole() {
return AccessibleRole.CHECK_BOX;
}
@@ -37,38 +48,38 @@
this(null, null, false);
}
- public JCheckBoxMenuItem(final Icon icon) {
+ public JCheckBoxMenuItem(Icon icon) {
this(null, icon, false);
}
- public JCheckBoxMenuItem(final String text) {
+ public JCheckBoxMenuItem(String text) {
this(text, null, false);
}
- public JCheckBoxMenuItem(final String text, final Icon icon) {
+ public JCheckBoxMenuItem(String text, Icon icon) {
this(text, icon, false);
}
- public JCheckBoxMenuItem(final String text, final boolean selected) {
+ public JCheckBoxMenuItem(String text, boolean selected) {
this(text, null, selected);
}
- public JCheckBoxMenuItem(final String text, final Icon icon,
- final boolean selected) {
+ public JCheckBoxMenuItem(String text, Icon icon, boolean selected) {
setDefaultModelAndFocus();
setSelected(selected);
init(text, icon);
}
- public JCheckBoxMenuItem(final Action action) {
+ public JCheckBoxMenuItem(Action action) {
super(action);
}
+ @Override
public String getUIClassID() {
return UI_CLASS_ID;
}
- public void setState(final boolean b) {
+ public void setState(boolean b) {
setSelected(b);
}
@@ -76,13 +87,14 @@
return isSelected();
}
+ @Override
public AccessibleContext getAccessibleContext() {
return (accessibleContext == null) ? (accessibleContext = new AccessibleJCheckBoxMenuItem())
: accessibleContext;
}
+ @Override
ButtonModel createDefaultModel() {
return new JToggleButton.ToggleButtonModel();
}
-
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JColorChooser.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JColorChooser.java?view=diff&rev=479197&r1=479196&r2=479197
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JColorChooser.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JColorChooser.java Sat Nov 25 12:56:42 2006
@@ -14,10 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/**
-* @author Sergey Burlak
-* @version $Revision$
-*/
+
package javax.swing;
import java.awt.BorderLayout;
@@ -30,7 +27,6 @@
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
@@ -40,41 +36,61 @@
import javax.swing.colorchooser.DefaultColorSelectionModel;
import javax.swing.plaf.ColorChooserUI;
+/**
+ * <p>
+ * <i>JColorChooser</i>
+ * </p>
+ * <h3>Implementation Notes:</h3>
+ * <ul>
+ * <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
+ * optimization, not as a guarantee of serialization compatibility.</li>
+ * </ul>
+ */
public class JColorChooser extends JComponent implements Accessible {
+ private static final long serialVersionUID = -3698198979867714534L;
+
protected class AccessibleJColorChooser extends AccessibleJComponent {
+ private static final long serialVersionUID = -4916849065058077868L;
+
+ @Override
public AccessibleRole getAccessibleRole() {
return AccessibleRole.COLOR_CHOOSER;
}
}
-
+
public static final String SELECTION_MODEL_PROPERTY = "selectionModel";
+
public static final String PREVIEW_PANEL_PROPERTY = "previewPanel";
+
public static final String CHOOSER_PANELS_PROPERTY = "chooserPanels";
-
+
private ColorSelectionModel colorSelectionModel;
+
private boolean dragEnabled;
+
private JComponent previewPanel;
+
private AbstractColorChooserPanel[] chooserPanels = new AbstractColorChooserPanel[] {};
+
private static Color resultColor;
public JColorChooser() {
this(new DefaultColorSelectionModel(Color.WHITE));
}
-
- public JColorChooser(final Color initialColor) {
+
+ public JColorChooser(Color initialColor) {
this(new DefaultColorSelectionModel(initialColor));
}
-
- public JColorChooser(final ColorSelectionModel model) {
+
+ public JColorChooser(ColorSelectionModel model) {
colorSelectionModel = model;
setLayout(new BorderLayout());
-
updateUI();
}
-
- public static Color showDialog(final Component component, final String title,
- final Color initialColor) throws HeadlessException {
-
+
+ @SuppressWarnings("deprecation")
+ public static Color showDialog(Component component, String title, Color initialColor)
+ throws HeadlessException {
final JColorChooser colorChooser = new JColorChooser(initialColor);
ActionListener okListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
@@ -87,21 +103,19 @@
}
};
createDialog(component, title, true, colorChooser, okListener, cancelListener).show();
-
return resultColor;
}
-
- public static JDialog createDialog(final Component c, final String title,
- final boolean modal, final JColorChooser chooserPane,
- final ActionListener okListener,
- final ActionListener cancelListener) throws HeadlessException {
-
- Window ancestingWindow = c instanceof Window ? (Window)c : SwingUtilities.getWindowAncestor(c);
+
+ public static JDialog createDialog(Component c, String title, boolean modal,
+ final JColorChooser chooserPane, ActionListener okListener,
+ ActionListener cancelListener) throws HeadlessException {
+ Window ancestingWindow = c instanceof Window ? (Window) c : SwingUtilities
+ .getWindowAncestor(c);
final JDialog result;
if (ancestingWindow instanceof Frame) {
- result = new JDialog((Frame)ancestingWindow);
+ result = new JDialog((Frame) ancestingWindow);
} else if (ancestingWindow instanceof Dialog) {
- result = new JDialog((Dialog)ancestingWindow);
+ result = new JDialog((Dialog) ancestingWindow);
} else {
result = new JDialog();
}
@@ -113,21 +127,17 @@
result.getRootPane().setWindowDecorationStyle(JRootPane.COLOR_CHOOSER_DIALOG);
}
JPanel buttonsPanel = new JPanel();
-
ActionListener disposeListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
result.dispose();
}
};
-
String okText = UIManager.getString("ColorChooser.okText");
final JButton okButton = new JButton(okText);
okButton.addActionListener(okListener);
-
String cancelText = UIManager.getString("ColorChooser.cancelText");
final JButton cancelButton = new JButton(cancelText);
cancelButton.addActionListener(cancelListener);
-
String resetText = UIManager.getString("ColorChooser.resetText");
JButton resetButton = new JButton(resetText);
int resetMnemonic = UIManager.getInt("ColorChooser.resetMnemonic");
@@ -137,10 +147,8 @@
chooserPane.setColor(Color.WHITE);
}
});
-
okButton.addActionListener(disposeListener);
cancelButton.addActionListener(disposeListener);
-
buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS));
buttonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 5));
buttonsPanel.add(Box.createHorizontalGlue());
@@ -149,89 +157,90 @@
buttonsPanel.add(cancelButton);
buttonsPanel.add(Box.createHorizontalStrut(6));
buttonsPanel.add(resetButton);
-
result.add(buttonsPanel, BorderLayout.SOUTH);
result.getRootPane().setDefaultButton(okButton);
-
result.pack();
-
- InputMap map = LookAndFeel.makeComponentInputMap(chooserPane, new Object[] { "ESCAPE", "cancelAction" });
- SwingUtilities.replaceUIInputMap(chooserPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, map);
+ InputMap map = LookAndFeel.makeComponentInputMap(chooserPane, new Object[] { "ESCAPE",
+ "cancelAction" });
+ SwingUtilities.replaceUIInputMap(chooserPane,
+ JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, map);
chooserPane.getActionMap().put("cancelAction", new AbstractAction() {
+ private static final long serialVersionUID = 1L;
+
public void actionPerformed(ActionEvent e) {
cancelButton.doClick(0);
}
});
-
return result;
}
-
+
public ColorChooserUI getUI() {
- return (ColorChooserUI)ui;
+ return (ColorChooserUI) ui;
}
-
- public void setUI(final ColorChooserUI ui) {
+
+ public void setUI(ColorChooserUI ui) {
super.setUI(ui);
}
-
+
+ @Override
public void updateUI() {
- setUI((ColorChooserUI)UIManager.getUI(this));
+ setUI((ColorChooserUI) UIManager.getUI(this));
}
-
+
+ @Override
public String getUIClassID() {
return "ColorChooserUI";
}
-
+
public Color getColor() {
return colorSelectionModel.getSelectedColor();
}
-
- public void setColor(final Color color) {
+
+ public void setColor(Color color) {
colorSelectionModel.setSelectedColor(color);
}
-
- public void setColor(final int r, final int g, final int b) {
+
+ public void setColor(int r, int g, int b) {
setColor(new Color(r, g, b));
}
-
- public void setColor(final int c) {
+
+ public void setColor(int c) {
setColor(new Color(c));
}
-
- public void setDragEnabled(final boolean b) {
+
+ public void setDragEnabled(boolean b) {
if (b && GraphicsEnvironment.isHeadless()) {
throw new HeadlessException();
}
dragEnabled = b;
}
-
+
public boolean getDragEnabled() {
return dragEnabled;
}
-
- public void setPreviewPanel(final JComponent preview) {
+
+ public void setPreviewPanel(JComponent preview) {
JComponent oldValue = previewPanel;
if (preview == null) {
previewPanel = ColorChooserComponentFactory.getPreviewPanel();
} else {
previewPanel = preview;
}
-
firePropertyChange(PREVIEW_PANEL_PROPERTY, oldValue, previewPanel);
}
-
+
public JComponent getPreviewPanel() {
return previewPanel;
}
-
- public void addChooserPanel(final AbstractColorChooserPanel panel) {
+
+ public void addChooserPanel(AbstractColorChooserPanel panel) {
AbstractColorChooserPanel[] newChooserPanels = new AbstractColorChooserPanel[chooserPanels.length + 1];
System.arraycopy(chooserPanels, 0, newChooserPanels, 0, chooserPanels.length);
newChooserPanels[chooserPanels.length] = panel;
setChooserPanels(newChooserPanels);
}
-
- public AbstractColorChooserPanel removeChooserPanel(final AbstractColorChooserPanel panel) {
+
+ public AbstractColorChooserPanel removeChooserPanel(AbstractColorChooserPanel panel) {
AbstractColorChooserPanel panelToRemove = null;
int index = 0;
for (int i = 0; i < chooserPanels.length; i++) {
@@ -241,45 +250,42 @@
break;
}
}
-
if (panelToRemove == null) {
throw new IllegalArgumentException("panel to remove can not be found");
}
-
AbstractColorChooserPanel[] newChooserPanels = new AbstractColorChooserPanel[chooserPanels.length - 1];
System.arraycopy(chooserPanels, 0, newChooserPanels, 0, index);
- System.arraycopy(chooserPanels, index + 1, newChooserPanels, index, newChooserPanels.length - index);
+ System.arraycopy(chooserPanels, index + 1, newChooserPanels, index,
+ newChooserPanels.length - index);
setChooserPanels(newChooserPanels);
-
return panelToRemove;
}
-
- public void setChooserPanels(final AbstractColorChooserPanel[] panels) {
+
+ public void setChooserPanels(AbstractColorChooserPanel[] panels) {
AbstractColorChooserPanel[] oldValue = chooserPanels;
chooserPanels = panels;
-
firePropertyChange(CHOOSER_PANELS_PROPERTY, oldValue, chooserPanels);
}
-
+
public AbstractColorChooserPanel[] getChooserPanels() {
return chooserPanels;
}
-
+
public ColorSelectionModel getSelectionModel() {
return colorSelectionModel;
}
-
- public void setSelectionModel(final ColorSelectionModel newModel) {
+
+ public void setSelectionModel(ColorSelectionModel newModel) {
ColorSelectionModel oldModel = colorSelectionModel;
colorSelectionModel = newModel;
firePropertyChange(SELECTION_MODEL_PROPERTY, oldModel, newModel);
}
-
+
+ @Override
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJColorChooser();
}
-
return accessibleContext;
}
}