[cp-patches] FYI: javax.swing.* source code formatting fixes

David Gilbert david.gilbert at object-refinery.com
Thu Jun 1 04:28:01 UTC 2006


This patch (committed) fixes some source code formatting issues pointed out by 
Checkstyle:

2006-06-01  David Gilbert  <david.gilbert at object-refinery.com>

	* javax/swing/JComboBox.java: Minor source code formatting fixes,
	* javax/swing/JEditorPane.java: Likewise,
	* javax/swing/JFormattedTextField.java: Likewise,
	* javax/swing/JLayeredPane.java: Likewise,
	* javax/swing/JScrollPane.java: Likewise,
	* javax/swing/JSlider.java: Likewise,
	* javax/swing/JSpinner.java: Likewise,
	* javax/swing/JTree.java: Likewise,
	* javax/swing/JViewport.java: Likewise,
	* javax/swing/UIDefaults.java: Likewise,
	* javax/swing/UIManager.java: Likewise.

Regards,

Dave
-------------- next part --------------
Index: javax/swing/JComboBox.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/JComboBox.java,v
retrieving revision 1.31
diff -u -r1.31 JComboBox.java
--- javax/swing/JComboBox.java	8 May 2006 20:42:55 -0000	1.31
+++ javax/swing/JComboBox.java	1 Jun 2006 04:30:09 -0000
@@ -675,7 +675,7 @@
       }
     else
       throw new RuntimeException("Unable to remove the items because the data "
-                                 +"model it is not an instance of "
+                                 + "model it is not an instance of "
                                  + "MutableComboBoxModel.");
   }
 
@@ -848,7 +848,7 @@
   {
     PopupMenuListener[] listeners = getPopupMenuListeners();
     PopupMenuEvent e = new PopupMenuEvent(this);
-    for(int i = 0; i < listeners.length; i++)
+    for (int i = 0; i < listeners.length; i++)
       listeners[i].popupMenuCanceled(e);
   }
 
@@ -862,7 +862,7 @@
   {
     PopupMenuListener[] listeners = getPopupMenuListeners();
     PopupMenuEvent e = new PopupMenuEvent(this);
-    for(int i = 0; i < listeners.length; i++)
+    for (int i = 0; i < listeners.length; i++)
       listeners[i].popupMenuWillBecomeInvisible(e);
   }
 
@@ -876,7 +876,7 @@
   {
     PopupMenuListener[] listeners = getPopupMenuListeners();
     PopupMenuEvent e = new PopupMenuEvent(this);
-    for(int i = 0; i < listeners.length; i++)
+    for (int i = 0; i < listeners.length; i++)
       listeners[i].popupMenuWillBecomeVisible(e);
   }
 
Index: javax/swing/JEditorPane.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/JEditorPane.java,v
retrieving revision 1.32
diff -u -r1.32 JEditorPane.java
--- javax/swing/JEditorPane.java	4 Mar 2006 09:50:24 -0000	1.32
+++ javax/swing/JEditorPane.java	1 Jun 2006 04:30:10 -0000
@@ -1,5 +1,5 @@
 /* JEditorPane.java --
-   Copyright (C) 2002, 2004, 2005  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005, 2006,  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -538,8 +538,8 @@
 
   public JEditorPane(URL url) throws IOException
   {
-    init ();
-    setEditorKit (createEditorKitForContentType("text/html"));;
+    init();
+    setEditorKit(createEditorKitForContentType("text/html"));;
     setPage(url);
   }
   
@@ -581,7 +581,7 @@
     // TODO: Have to handle the case where a ClassLoader was specified
     // when the EditorKit was registered
     EditorKit e = null;
-    String className = (String)registerMap.get(type);
+    String className = (String) registerMap.get(type);
     if (className != null)
       {
         try
Index: javax/swing/JFormattedTextField.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/JFormattedTextField.java,v
retrieving revision 1.19
diff -u -r1.19 JFormattedTextField.java
--- javax/swing/JFormattedTextField.java	2 Dec 2005 16:22:53 -0000	1.19
+++ javax/swing/JFormattedTextField.java	1 Jun 2006 04:30:11 -0000
@@ -101,11 +101,11 @@
      * @throws CloneNotSupportedException if the Object's class doesn't support
      * the {@link Cloneable} interface
      */
-    protected Object clone ()
+    protected Object clone()
       throws CloneNotSupportedException
     {
       // Clone this formatter.
-      AbstractFormatter newFormatter = (AbstractFormatter)super.clone();
+      AbstractFormatter newFormatter = (AbstractFormatter) super.clone();
       
       // And remove the association to the JFormattedTextField.
       newFormatter.textField = null;
@@ -119,7 +119,7 @@
      * @return <code>null</code>.  Should be subclassed by formatters that want
      * to install custom Actions on the JFormattedTextField.
      */
-    protected Action[] getActions ()
+    protected Action[] getActions()
     {
       return null;
     }
@@ -132,7 +132,7 @@
      * @return <code>null</code>.  Should be subclassed by formatters
      * that want to restrict Document mutations.
      */
-    protected DocumentFilter getDocumentFilter ()
+    protected DocumentFilter getDocumentFilter()
     {
       // Subclasses should override this if they want to install a 
       // DocumentFilter.
@@ -146,7 +146,7 @@
      * @return the JFormattedTextField on which this formatter is currently
      * installed
      */
-    protected JFormattedTextField getFormattedTextField ()
+    protected JFormattedTextField getFormattedTextField()
     {
       return textField;
     }
@@ -159,7 +159,7 @@
      * @return <code>null</code>.  Subclassed by formatters that want to restrict
      * cursor location within the JFormattedTextField.
      */
-    protected NavigationFilter getNavigationFilter ()
+    protected NavigationFilter getNavigationFilter()
     {
       // This should be subclassed if the formatter wants to install 
       // a NavigationFilter on the JFormattedTextField.
@@ -199,7 +199,7 @@
             
             // Set the DocumentFilter for the field's Document.
             if (doc instanceof AbstractDocument)
-              ((AbstractDocument)doc).setDocumentFilter(getDocumentFilter());
+              ((AbstractDocument) doc).setDocumentFilter(getDocumentFilter());
             
             // Set the NavigationFilter.
             textField.setNavigationFilter(getNavigationFilter());
@@ -221,12 +221,12 @@
      * This resets the DocumentFilter, NavigationFilter, and any additional 
      * Actions (returned by <code>getActions()</code>).     
      */
-    public void uninstall ()
+    public void uninstall()
     {
       // Set the DocumentFilter for the field's Document.
       Document doc = textField.getDocument();
       if (doc instanceof AbstractDocument)
-        ((AbstractDocument)doc).setDocumentFilter(null);
+        ((AbstractDocument) doc).setDocumentFilter(null);
       textField.setNavigationFilter(null);
       // FIXME: Have to remove the Actions from getActions()
       this.textField = null;
@@ -236,7 +236,7 @@
      * Invoke this method when invalid values are entered.  This forwards the
      * call to the JFormattedTextField.     
      */
-    protected void invalidEdit ()
+    protected void invalidEdit()
     {
       textField.invalidEdit();
     }
@@ -247,7 +247,7 @@
      * 
      * @param valid the new state for the <code>editValid</code> property
      */
-    protected void setEditValid (boolean valid)
+    protected void setEditValid(boolean valid)
     {
       textField.editValid = valid;
     }
@@ -259,7 +259,7 @@
      * @return an Object that <code>text</code> represented
      * @throws ParseException if there is an error in the conversion
      */
-    public abstract Object stringToValue (String text)
+    public abstract Object stringToValue(String text)
       throws ParseException;
 
     /**
@@ -270,7 +270,7 @@
      * @return a String to be displayed
      * @throws ParseException if there is an error in the conversion
      */
-    public abstract String valueToString (Object value)
+    public abstract String valueToString(Object value)
       throws ParseException;
   }
 
@@ -280,12 +280,12 @@
    */
   public abstract static class AbstractFormatterFactory
   {
-    public AbstractFormatterFactory ()
+    public AbstractFormatterFactory()
     {
       // Do nothing here.
     }
 
-    public abstract AbstractFormatter getFormatter (JFormattedTextField tf);
+    public abstract AbstractFormatter getFormatter(JFormattedTextField tf);
   }
 
   /** The possible focusLostBehavior options **/
@@ -315,7 +315,7 @@
    * properly configure this text field to edit a particular type
    * of value.
    */
-  public JFormattedTextField ()
+  public JFormattedTextField()
   {
     this((AbstractFormatterFactory) null, null);
   }
@@ -328,7 +328,7 @@
    * @param format the Format that this JFormattedTextField should be able
    * to handle
    */
-  public JFormattedTextField (Format format)
+  public JFormattedTextField(Format format)
   {
     this ();
     setFormatterFactory(getAppropriateFormatterFactory(format));
@@ -341,9 +341,9 @@
    * 
    * @param formatter the formatter to use for this JFormattedTextField
    */
-  public JFormattedTextField (AbstractFormatter formatter)
+  public JFormattedTextField(AbstractFormatter formatter)
   {
-    this(new DefaultFormatterFactory (formatter));
+    this(new DefaultFormatterFactory(formatter));
   }
 
   /**
@@ -351,7 +351,7 @@
    * 
    * @param factory the formatter factory to use for this JFormattedTextField
    */
-  public JFormattedTextField (AbstractFormatterFactory factory)
+  public JFormattedTextField(AbstractFormatterFactory factory)
   {
     setFormatterFactory(factory);
   }
@@ -363,7 +363,7 @@
    * @param factory the initial formatter factory for this JFormattedTextField
    * @param value the initial value for the text field
    */
-  public JFormattedTextField (AbstractFormatterFactory factory, Object value)
+  public JFormattedTextField(AbstractFormatterFactory factory, Object value)
   {    
     setFormatterFactory(factory);
     setValue(value);
@@ -375,7 +375,7 @@
    * 
    * @param value the initial value for this JFormattedTextField
    */
-  public JFormattedTextField (Object value)
+  public JFormattedTextField(Object value)
   {
     setValue(value);
   }
@@ -387,13 +387,13 @@
    * @return a DefaultFormatterFactory whose defaultFormatter is appropriate
    * for the given Format.
    */
-  private AbstractFormatterFactory getAppropriateFormatterFactory (Format format)
+  private AbstractFormatterFactory getAppropriateFormatterFactory(Format format)
   {
     AbstractFormatter newFormatter;
     if (format instanceof DateFormat)
-      newFormatter = new DateFormatter((DateFormat)format);
+      newFormatter = new DateFormatter((DateFormat) format);
     else if (format instanceof NumberFormat)
-      newFormatter = new NumberFormatter ((NumberFormat)format);
+      newFormatter = new NumberFormatter ((NumberFormat) format);
     else
       newFormatter = new InternationalFormatter(format);
     
@@ -406,7 +406,7 @@
    * 
    * @throws ParseException if the formatter cannot format the current value
    */
-  public void commitEdit ()
+  public void commitEdit()
     throws ParseException
   {
     if (formatter == null)
@@ -427,7 +427,7 @@
    * 
    * @return an array of Actions that this text field supports
    */
-  public Action[] getActions ()
+  public Action[] getActions()
   {
     // FIXME: Add JFormattedTextField specific actions
     // These are related to committing or cancelling edits.
@@ -449,7 +449,7 @@
    * Returns the current formatter used for this JFormattedTextField.
    * @return the current formatter used for this JFormattedTextField
    */
-  public AbstractFormatter getFormatter ()
+  public AbstractFormatter getFormatter()
   {
     return formatter;
   }
@@ -459,12 +459,12 @@
    * JFormattedTextField.
    * @return the factory currently used to generate formatters
    */
-  public AbstractFormatterFactory getFormatterFactory ()
+  public AbstractFormatterFactory getFormatterFactory()
   {
     return formatterFactory;
   }
 
-  public String getUIClassID ()
+  public String getUIClassID()
   {
     return "FormattedTextFieldUI";
   }
@@ -475,7 +475,7 @@
    * valid edits and allows invalid input to be temporarily displayed.  
    * @return the last committed valid value
    */
-  public Object getValue ()
+  public Object getValue()
   {
     return value;
   }
@@ -484,7 +484,7 @@
    * This method is used to provide feedback to the user when an invalid value
    * is input during editing.   
    */
-  protected void invalidEdit ()
+  protected void invalidEdit()
   {
     UIManager.getLookAndFeel().provideErrorFeedback(this);
   }
@@ -494,7 +494,7 @@
    * managed by the current formatted.
    * @return true if the value being edited is valid.
    */
-  public boolean isEditValid ()
+  public boolean isEditValid()
   {
     return editValid;
   }
@@ -506,7 +506,7 @@
    * 
    * @param evt the FocusEvent
    */
-  protected void processFocusEvent (FocusEvent evt)
+  protected void processFocusEvent(FocusEvent evt)
   {
     super.processFocusEvent(evt);
     // Let the formatterFactory change the formatter for this text field
@@ -561,7 +561,7 @@
    * @param formatter the AbstractFormatter to use for formatting the value for
    * this JFormattedTextField
    */
-  protected void setFormatter (AbstractFormatter formatter)
+  protected void setFormatter(AbstractFormatter formatter)
   {
     AbstractFormatter oldFormatter = null;
     
@@ -585,7 +585,7 @@
    * @param factory the AbstractFormatterFactory that will be used to generate
    * formatters for this JFormattedTextField
    */
-  public void setFormatterFactory (AbstractFormatterFactory factory)
+  public void setFormatterFactory(AbstractFormatterFactory factory)
   {
     if (formatterFactory == factory)
       return;
@@ -606,7 +606,7 @@
    *   
    * @param newValue the value to be formatted and displayed
    */
-  public void setValue (Object newValue)
+  public void setValue(Object newValue)
   {
     if (value == newValue)
       return;
Index: javax/swing/JLayeredPane.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/JLayeredPane.java,v
retrieving revision 1.45
diff -u -r1.45 JLayeredPane.java
--- javax/swing/JLayeredPane.java	28 Mar 2006 21:47:14 -0000	1.45
+++ javax/swing/JLayeredPane.java	1 Jun 2006 04:30:12 -0000
@@ -147,19 +147,19 @@
   
   public static final String LAYER_PROPERTY = "layeredContainerLayer";
 
-  public static final Integer FRAME_CONTENT_LAYER = new Integer (-30000);
+  public static final Integer FRAME_CONTENT_LAYER = new Integer(-30000);
 
-  public static final Integer DEFAULT_LAYER = new Integer (0);
-  public static final Integer PALETTE_LAYER = new Integer (100);
-  public static final Integer MODAL_LAYER   = new Integer (200);
-  public static final Integer POPUP_LAYER   = new Integer (300);
-  public static final Integer DRAG_LAYER    = new Integer (400);
+  public static final Integer DEFAULT_LAYER = new Integer(0);
+  public static final Integer PALETTE_LAYER = new Integer(100);
+  public static final Integer MODAL_LAYER   = new Integer(200);
+  public static final Integer POPUP_LAYER   = new Integer(300);
+  public static final Integer DRAG_LAYER    = new Integer(400);
 
   private Hashtable componentToLayer;   // Component -> Layer Number (Integer)
 
   public JLayeredPane()
   {
-    componentToLayer = new Hashtable ();
+    componentToLayer = new Hashtable();
     setLayout(null);
   }
 
Index: javax/swing/JScrollPane.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/JScrollPane.java,v
retrieving revision 1.31
diff -u -r1.31 JScrollPane.java
--- javax/swing/JScrollPane.java	20 Apr 2006 19:50:39 -0000	1.31
+++ javax/swing/JScrollPane.java	1 Jun 2006 04:30:13 -0000
@@ -170,7 +170,8 @@
     return columnHeader;
   }
 
-  public Component getCorner(String key) {
+  public Component getCorner(String key) 
+  {
     if (getComponentOrientation() 
         == ComponentOrientation.LEFT_TO_RIGHT)
       {
@@ -247,7 +248,7 @@
     if (viewportBorder == null)
       {
         if (getViewport() == null)
-          return new Rectangle(0,0,0,0);
+          return new Rectangle(0, 0, 0, 0);
         else
           return getViewport().getBounds();
       }
@@ -255,8 +256,7 @@
       {
         Insets i = viewportBorder.getBorderInsets(getViewport());
         if (getViewport() == null)
-          return new Rectangle(0,0,
-                               i.left+i.right, i.top+i.bottom);
+          return new Rectangle(0, 0, i.left + i.right, i.top + i.bottom);
         else
           {
             Rectangle b = getViewport().getBounds();
Index: javax/swing/JSlider.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/JSlider.java,v
retrieving revision 1.28
diff -u -r1.28 JSlider.java
--- javax/swing/JSlider.java	20 Apr 2006 13:09:20 -0000	1.28
+++ javax/swing/JSlider.java	1 Jun 2006 04:30:14 -0000
@@ -227,13 +227,13 @@
   }
 
   /** Whether or not this slider paints its ticks. */
-  private transient boolean paintTicks = false;
+  private transient boolean paintTicks;
 
   /** Whether or not this slider paints its track. */
   private transient boolean paintTrack = true;
 
   /** Whether or not this slider paints its labels. */
-  private transient boolean paintLabels = false;
+  private transient boolean paintLabels;
 
   /**
    * A dictionary of (Integer, Component) pairs where each Component is a
@@ -251,7 +251,7 @@
   protected int minorTickSpacing;
 
   /** Whether the slider snaps its values to ticks. */
-  protected boolean snapToTicks = false;
+  protected boolean snapToTicks;
 
   /** The orientation (horizontal or vertical) of the slider. */
   protected int orientation = HORIZONTAL;
Index: javax/swing/JSpinner.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/JSpinner.java,v
retrieving revision 1.16
diff -u -r1.16 JSpinner.java
--- javax/swing/JSpinner.java	28 Apr 2006 17:35:16 -0000	1.16
+++ javax/swing/JSpinner.java	1 Jun 2006 04:30:16 -0000
@@ -106,7 +106,7 @@
       add(ftf);
       ftf.setValue(spinner.getValue());
       ftf.addPropertyChangeListener(this);
-      if(getComponentOrientation().isLeftToRight())
+      if (getComponentOrientation().isLeftToRight())
 	ftf.setHorizontalAlignment(JTextField.RIGHT);
       else
 	ftf.setHorizontalAlignment(JTextField.LEFT);
Index: javax/swing/JTree.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/JTree.java,v
retrieving revision 1.66
diff -u -r1.66 JTree.java
--- javax/swing/JTree.java	27 Apr 2006 08:23:45 -0000	1.66
+++ javax/swing/JTree.java	1 Jun 2006 04:30:19 -0000
@@ -1142,9 +1142,9 @@
 
     public boolean isLeaf()
     {
-      return (childValue == null || !(childValue instanceof Hashtable
-          || childValue instanceof Vector || childValue.getClass()
-          .isArray()));
+      return childValue == null || !(childValue instanceof Hashtable
+          || childValue instanceof Vector 
+          || childValue.getClass().isArray());
     }
 
     public static void createChildren(DefaultMutableTreeNode parent,
@@ -2316,7 +2316,7 @@
             selectionModel.addSelectionPath(path);
           }
         
-        if (oldValue!=null)
+        if (oldValue != null)
           repaint(getPathBounds(oldValue));
         
         firePropertyChange(LEAD_SELECTION_PATH_PROPERTY, oldValue, path);
Index: javax/swing/JViewport.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/JViewport.java,v
retrieving revision 1.45
diff -u -r1.45 JViewport.java
--- javax/swing/JViewport.java	27 Feb 2006 13:02:34 -0000	1.45
+++ javax/swing/JViewport.java	1 Jun 2006 04:30:20 -0000
@@ -877,7 +877,7 @@
           {
             // If the image has not been scrolled at all, only the changed
             // clip must be updated in the buffer.
-            if (dx==0 && dy==0)
+            if (dx == 0 && dy == 0)
               g2.setClip(g.getClip());
             
             paintSimple(g2);
Index: javax/swing/UIDefaults.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/UIDefaults.java,v
retrieving revision 1.26
diff -u -r1.26 UIDefaults.java
--- javax/swing/UIDefaults.java	21 Dec 2005 21:04:56 -0000	1.26
+++ javax/swing/UIDefaults.java	1 Jun 2006 04:30:21 -0000
@@ -96,15 +96,15 @@
     }
     public Object createValue(UIDefaults table)
     {
-      InputMapUIResource im = new InputMapUIResource ();
-      for (int i = 0; 2*i+1 < bind.length; ++i)
+      InputMapUIResource im = new InputMapUIResource();
+      for (int i = 0; 2 * i + 1 < bind.length; ++i)
         {
-          Object curr = bind[2*i];
+          Object curr = bind[2 * i];
           if (curr instanceof KeyStroke)
-            im.put((KeyStroke) curr, bind[2*i+1]);
+            im.put((KeyStroke) curr, bind[2 * i + 1]);
           else
             im.put(KeyStroke.getKeyStroke((String) curr),
-                  bind[2*i+1]);
+                  bind[2 * i + 1]);
         }
       return im;
     }
@@ -128,9 +128,9 @@
     public ProxyLazyValue(String s)
     {
       final String className = s;
-      inner = new LazyValue ()
+      inner = new LazyValue()
         { 
-          public Object createValue (UIDefaults table) 
+          public Object createValue(UIDefaults table) 
           {
             try
               {
@@ -151,16 +151,16 @@
     {
       final String className = c;
       final String methodName = m;
-      inner = new LazyValue ()
+      inner = new LazyValue()
         { 
-          public Object createValue (UIDefaults table) 
+          public Object createValue(UIDefaults table) 
           {
             try 
               {                
                 return Class
-                  .forName (className)
-                  .getMethod (methodName, new Class[] {})
-                  .invoke (null, new Object[] {});
+                  .forName(className)
+                  .getMethod(methodName, new Class[] {})
+                  .invoke(null, new Object[] {});
               }
             catch (Exception e)
               {
@@ -674,7 +674,7 @@
    */
   public Class getUIClass(String id, ClassLoader loader)
   {
-    String className = (String) get (id);
+    String className = (String) get(id);
     if (className == null)
       return null;
     try 
Index: javax/swing/UIManager.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/UIManager.java,v
retrieving revision 1.34
diff -u -r1.34 UIManager.java
--- javax/swing/UIManager.java	20 Apr 2006 19:50:39 -0000	1.34
+++ javax/swing/UIManager.java	1 Jun 2006 04:30:22 -0000
@@ -145,18 +145,19 @@
   static
   {
     String defaultlaf = System.getProperty("swing.defaultlaf");
-    try {
-      if (defaultlaf != null)
-        {
-          Class lafClass = Class.forName(defaultlaf);
-          LookAndFeel laf = (LookAndFeel) lafClass.newInstance();
-          setLookAndFeel(laf);
-        }
-      else
-        {
-          setLookAndFeel(new MetalLookAndFeel());
-        }
-    }
+    try 
+      {
+        if (defaultlaf != null)
+          {
+            Class lafClass = Class.forName(defaultlaf);
+            LookAndFeel laf = (LookAndFeel) lafClass.newInstance();
+            setLookAndFeel(laf);
+          }
+        else
+          {
+            setLookAndFeel(new MetalLookAndFeel());
+          }
+      }
     catch (Exception ex)
       {
         System.err.println("cannot initialize Look and Feel: " + defaultlaf);
@@ -455,7 +456,7 @@
    */
   public static Font getFont(Object key, Locale locale)
   {
-    return (Font) get(key ,locale);
+    return (Font) get(key, locale);
   }
 
   /**


More information about the Classpath-patches mailing list