[cp-patches] FYI: javax.swing.plaf.basic.* source code formatting fixlets

David Gilbert david.gilbert at object-refinery.com
Thu Jun 1 05:06:30 UTC 2006


This patch (committed) fixes some minor formatting/style issues in 
javax.swing.plaf.basic.*:

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

	* javax/swing/plaf/basic/BasicButtonUI.java: Minor source code style
	fixes,
	* javax/swing/plaf/basic/BasicDirectoryModel.java: Likewise,
	* javax/swing/plaf/basic/BasicFileChooserUI.java: Likewise,
	* javax/swing/plaf/basic/BasicIconFactory.java: Likewise,
	* javax/swing/plaf/basic/BasicListUI.java: Likewise,
	* javax/swing/plaf/basic/BasicOptionPaneUI.java: Likewise,
	* javax/swing/plaf/basic/BasicRootPaneUI.java: Likewise,
	* javax/swing/plaf/basic/BasicScrollPaneUI.java: Likewise,
	* javax/swing/plaf/basic/BasicSpinnerUI.java: Likewise,
	* javax/swing/plaf/basic/BasicTabbedPaneUI.java: Likewise,
	* javax/swing/plaf/basic/BasicTextAreaUI.java: Likewise.

Regards,

Dave
-------------- next part --------------
Index: javax/swing/plaf/basic/BasicButtonUI.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/plaf/basic/BasicButtonUI.java,v
retrieving revision 1.37
diff -u -r1.37 BasicButtonUI.java
--- javax/swing/plaf/basic/BasicButtonUI.java	21 Mar 2006 14:53:47 -0000	1.37
+++ javax/swing/plaf/basic/BasicButtonUI.java	1 Jun 2006 05:11:20 -0000
@@ -72,7 +72,7 @@
    * A constant added to the defaultTextIconGap to adjust the text
    * within this particular button.
    */
-  protected int defaultTextShiftOffset = 0;
+  protected int defaultTextShiftOffset;
 
   private int textShiftOffset;
 
@@ -268,10 +268,9 @@
    */
   public Dimension getPreferredSize(JComponent c) 
   {
-    AbstractButton b = (AbstractButton)c;
-    Dimension d = 
-      BasicGraphicsUtils.getPreferredButtonSize
-      (b, defaultTextIconGap + defaultTextShiftOffset);
+    AbstractButton b = (AbstractButton) c;
+    Dimension d = BasicGraphicsUtils.getPreferredButtonSize(b, 
+        defaultTextIconGap + defaultTextShiftOffset);
     return d;
   }
 
Index: javax/swing/plaf/basic/BasicDirectoryModel.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/plaf/basic/BasicDirectoryModel.java,v
retrieving revision 1.2
diff -u -r1.2 BasicDirectoryModel.java
--- javax/swing/plaf/basic/BasicDirectoryModel.java	2 Jul 2005 20:32:50 -0000	1.2
+++ javax/swing/plaf/basic/BasicDirectoryModel.java	1 Jun 2006 05:11:21 -0000
@@ -227,16 +227,16 @@
 
     if (aTrav == bTrav)
       {
-	String aname = a.getName().toLowerCase();
-	String bname = b.getName().toLowerCase();
-	return ((aname.compareTo(bname) < 0) ? true : false);
+        String aname = a.getName().toLowerCase();
+        String bname = b.getName().toLowerCase();
+        return (aname.compareTo(bname) < 0) ? true : false;
       }
     else
       {
-	if (aTrav)
-	  return true;
-	else
-	  return false;
+        if (aTrav)
+          return true;
+        else
+          return false;
       }
   }
 
Index: javax/swing/plaf/basic/BasicFileChooserUI.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java,v
retrieving revision 1.24
diff -u -r1.24 BasicFileChooserUI.java
--- javax/swing/plaf/basic/BasicFileChooserUI.java	19 Mar 2006 20:19:51 -0000	1.24
+++ javax/swing/plaf/basic/BasicFileChooserUI.java	1 Jun 2006 05:11:22 -0000
@@ -365,10 +365,10 @@
   {
 
     /** DOCUMENT ME! */
-    private Object lastSelected = null;
+    private Object lastSelected;
 
     /** DOCUMENT ME! */
-    private JList list = null;
+    private JList list;
 
     /**
      * Creates a new DoubleClickListener object.
Index: javax/swing/plaf/basic/BasicIconFactory.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/plaf/basic/BasicIconFactory.java,v
retrieving revision 1.13
diff -u -r1.13 BasicIconFactory.java
--- javax/swing/plaf/basic/BasicIconFactory.java	29 Sep 2005 08:53:11 -0000	1.13
+++ javax/swing/plaf/basic/BasicIconFactory.java	1 Jun 2006 05:11:23 -0000
@@ -56,8 +56,14 @@
   private static class DummyIcon 
     implements Icon
   {    
-    public int getIconHeight() { return 10; }
-    public int getIconWidth() { return 10; }
+    public int getIconHeight() 
+    { 
+      return 10; 
+    }
+    public int getIconWidth() 
+    { 
+      return 10; 
+    }
     public void paintIcon(Component c, Graphics g, int x, int y)
     {
       Color save = g.getColor();
Index: javax/swing/plaf/basic/BasicListUI.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/plaf/basic/BasicListUI.java,v
retrieving revision 1.57
diff -u -r1.57 BasicListUI.java
--- javax/swing/plaf/basic/BasicListUI.java	17 Apr 2006 07:41:05 -0000	1.57
+++ javax/swing/plaf/basic/BasicListUI.java	1 Jun 2006 05:11:24 -0000
@@ -218,11 +218,12 @@
   
   class ListAction extends AbstractAction
   {
-    public void actionPerformed (ActionEvent e)
+    public void actionPerformed(ActionEvent e)
     {
       int lead = list.getLeadSelectionIndex();
       int max = list.getModel().getSize() - 1;
-      DefaultListSelectionModel selModel = (DefaultListSelectionModel)list.getSelectionModel();
+      DefaultListSelectionModel selModel 
+          = (DefaultListSelectionModel) list.getSelectionModel();
       String command = e.getActionCommand();
       // Do nothing if list is empty
       if (max == -1)
@@ -260,9 +261,8 @@
           int target;
           if (lead == list.getLastVisibleIndex())
             {
-              target = Math.min
-                (max, lead + (list.getLastVisibleIndex() -
-                    list.getFirstVisibleIndex() + 1));
+              target = Math.min(max, lead + (list.getLastVisibleIndex() 
+                  - list.getFirstVisibleIndex() + 1));
             }
           else
             target = list.getLastVisibleIndex();
@@ -273,9 +273,8 @@
           int target;
           if (lead == list.getLastVisibleIndex())
             {
-              target = Math.min
-                (max, lead + (list.getLastVisibleIndex() -
-                    list.getFirstVisibleIndex() + 1));
+              target = Math.min(max, lead + (list.getLastVisibleIndex() 
+                  - list.getFirstVisibleIndex() + 1));
             }
           else
             target = list.getLastVisibleIndex();
@@ -286,9 +285,8 @@
           int target;
           if (lead == list.getFirstVisibleIndex())
             {
-              target = Math.max 
-                (0, lead - (list.getLastVisibleIndex() - 
-                    list.getFirstVisibleIndex() + 1));
+              target = Math.max(0, lead - (list.getLastVisibleIndex() 
+                  - list.getFirstVisibleIndex() + 1));
             }
           else
             target = list.getFirstVisibleIndex();
@@ -299,9 +297,8 @@
           int target;
           if (lead == list.getFirstVisibleIndex())
             {
-              target = Math.max 
-                (0, lead - (list.getLastVisibleIndex() - 
-                    list.getFirstVisibleIndex() + 1));
+              target = Math.max(0, lead - (list.getLastVisibleIndex() 
+                  - list.getFirstVisibleIndex() + 1));
             }
           else
             target = list.getFirstVisibleIndex();
@@ -309,32 +306,31 @@
         }
       else if (command.equals("selectNextRowExtendSelection"))
         {
-          selModel.setLeadSelectionIndex(Math.min(lead + 1,max));
+          selModel.setLeadSelectionIndex(Math.min(lead + 1, max));
         }
       else if (command.equals("selectFirstRow"))
         {
           list.setSelectedIndex(0);
         }
       else if (command.equals("selectFirstRowChangeLead"))
-          {
-            selModel.moveLeadSelectionIndex(0);
-          }
+        {
+          selModel.moveLeadSelectionIndex(0);
+        }
       else if (command.equals("selectFirstRowExtendSelection"))
         {
           selModel.setLeadSelectionIndex(0);
         }
       else if (command.equals("selectPreviousRowExtendSelection"))
         {
-          selModel.setLeadSelectionIndex(Math.max(0,lead - 1));
+          selModel.setLeadSelectionIndex(Math.max(0, lead - 1));
         }
       else if (command.equals("scrollUp"))
         {
           int target;
           if (lead == list.getFirstVisibleIndex())
             {
-              target = Math.max 
-                (0, lead - (list.getLastVisibleIndex() - 
-                    list.getFirstVisibleIndex() + 1));
+              target = Math.max(0, lead - (list.getLastVisibleIndex() 
+                  - list.getFirstVisibleIndex() + 1));
             }
           else
             target = list.getFirstVisibleIndex();
@@ -349,9 +345,8 @@
           int target;
           if (lead == list.getLastVisibleIndex())
             {
-              target = Math.min
-                (max, lead + (list.getLastVisibleIndex() -
-                    list.getFirstVisibleIndex() + 1));
+              target = Math.min(max, lead + (list.getLastVisibleIndex() 
+                  - list.getFirstVisibleIndex() + 1));
             }
           else
             target = list.getLastVisibleIndex();
@@ -451,9 +446,9 @@
           if (list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION)
             list.setSelectedIndex(index);
           else if (list.isSelectedIndex(index))
-            list.removeSelectionInterval(index,index);
+            list.removeSelectionInterval(index, index);
           else
-            list.addSelectionInterval(index,index);
+            list.addSelectionInterval(index, index);
         }
       else
         list.setSelectedIndex(index);
@@ -1006,14 +1001,14 @@
     // Register key bindings in the UI InputMap-ActionMap pair
     for (int i = 0; i < keys.length; i++)
       {
-        KeyStroke stroke = (KeyStroke)keys[i];
+        KeyStroke stroke = (KeyStroke) keys[i];
         String actionString = (String) focusInputMap.get(stroke);
         parentInputMap.put(KeyStroke.getKeyStroke(stroke.getKeyCode(),
                                                   stroke.getModifiers()),
                            actionString);
 
-        parentActionMap.put (actionString, 
-                             new ActionListenerProxy(action, actionString));
+        parentActionMap.put(actionString, 
+                            new ActionListenerProxy(action, actionString));
       }
     // Register the new InputMap-ActionMap as the parents of the list's
     // InputMap and ActionMap
Index: javax/swing/plaf/basic/BasicOptionPaneUI.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java,v
retrieving revision 1.29
diff -u -r1.29 BasicOptionPaneUI.java
--- javax/swing/plaf/basic/BasicOptionPaneUI.java	17 Apr 2006 07:41:05 -0000	1.29
+++ javax/swing/plaf/basic/BasicOptionPaneUI.java	1 Jun 2006 05:11:26 -0000
@@ -977,7 +977,7 @@
       case JOptionPane.OK_CANCEL_OPTION:
 	return new Object[] { OK_STRING, CANCEL_STRING };
       case JOptionPane.DEFAULT_OPTION:
-        return (optionPane.getWantsInput() ) ?
+        return (optionPane.getWantsInput()) ?
                new Object[] { OK_STRING, CANCEL_STRING } :
                ( optionPane.getMessageType() == JOptionPane.QUESTION_MESSAGE ) ?
                new Object[] { YES_STRING, NO_STRING, CANCEL_STRING } :
Index: javax/swing/plaf/basic/BasicRootPaneUI.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/plaf/basic/BasicRootPaneUI.java,v
retrieving revision 1.13
diff -u -r1.13 BasicRootPaneUI.java
--- javax/swing/plaf/basic/BasicRootPaneUI.java	25 Mar 2006 00:01:59 -0000	1.13
+++ javax/swing/plaf/basic/BasicRootPaneUI.java	1 Jun 2006 05:11:26 -0000
@@ -215,9 +215,8 @@
                                        JComponent.WHEN_IN_FOCUSED_WINDOW);
         if (newValue != null)
           {
-            Object[] keybindings =
-              (Object[]) UIManager.get
-              ("RootPane.defaultButtonWindowKeyBindings");
+            Object[] keybindings = (Object[]) UIManager.get(
+                "RootPane.defaultButtonWindowKeyBindings");
             LookAndFeel.loadKeyBindings(im, keybindings);
           }
         else
Index: javax/swing/plaf/basic/BasicScrollPaneUI.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/plaf/basic/BasicScrollPaneUI.java,v
retrieving revision 1.24
diff -u -r1.24 BasicScrollPaneUI.java
--- javax/swing/plaf/basic/BasicScrollPaneUI.java	17 Apr 2006 07:41:05 -0000	1.24
+++ javax/swing/plaf/basic/BasicScrollPaneUI.java	1 Jun 2006 05:11:28 -0000
@@ -545,7 +545,7 @@
   public void uninstallUI(final JComponent c) 
   {
     super.uninstallUI(c);
-    this.uninstallDefaults((JScrollPane)c);
+    this.uninstallDefaults((JScrollPane) c);
     uninstallListeners((JScrollPane) c);
     installKeyboardActions((JScrollPane) c);
   }
@@ -590,7 +590,7 @@
 
   public Dimension getMinimumSize(JComponent c) 
   {
-    JScrollPane p = (JScrollPane ) c;
+    JScrollPane p = (JScrollPane) c;
     ScrollPaneLayout sl = (ScrollPaneLayout) p.getLayout();
     return sl.minimumLayoutSize(c);
   }
Index: javax/swing/plaf/basic/BasicSpinnerUI.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/plaf/basic/BasicSpinnerUI.java,v
retrieving revision 1.10
diff -u -r1.10 BasicSpinnerUI.java
--- javax/swing/plaf/basic/BasicSpinnerUI.java	28 Apr 2006 17:35:16 -0000	1.10
+++ javax/swing/plaf/basic/BasicSpinnerUI.java	1 Jun 2006 05:11:28 -0000
@@ -220,7 +220,7 @@
 	      BasicSpinnerUI.this.spinner.getModel().setValue(next);
 	  }
 
-	  volatile boolean mouseDown = false;
+	  volatile boolean mouseDown;
 	  Timer timer = new Timer(50,
 	                          new ActionListener()
 	      {
@@ -260,7 +260,7 @@
 	      BasicSpinnerUI.this.spinner.getModel().setValue(prev);
 	  }
 
-	  volatile boolean mouseDown = false;
+	  volatile boolean mouseDown;
 	  Timer timer = new Timer(50,
 	                          new ActionListener()
 	      {
Index: javax/swing/plaf/basic/BasicTabbedPaneUI.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java,v
retrieving revision 1.43
diff -u -r1.43 BasicTabbedPaneUI.java
--- javax/swing/plaf/basic/BasicTabbedPaneUI.java	30 Apr 2006 09:34:21 -0000	1.43
+++ javax/swing/plaf/basic/BasicTabbedPaneUI.java	1 Jun 2006 05:11:33 -0000
@@ -286,7 +286,7 @@
           width = Math.max(min, width);
           int tabAreaHeight = preferredTabAreaHeight(tabPlacement,
                                                      width - tabAreaInsets.left
-                                                     -tabAreaInsets.right);
+                                                     - tabAreaInsets.right);
           height += tabAreaHeight;
         }
       else
@@ -476,7 +476,7 @@
           else
             nextIndex = i + 1;
           int next = tabRuns[nextIndex];
-          int end = (next != 0 ? next - 1 : tabCount - 1);
+          int end = next != 0 ? next - 1 : tabCount - 1;
           if (tabPlacement == SwingConstants.TOP
               || tabPlacement == SwingConstants.BOTTOM)
             {
@@ -491,9 +491,9 @@
                   padTabRun(tabPlacement, start, end, breakAt);
                 }
               if (tabPlacement == BOTTOM)
-                y -= (maxTabHeight - tabRunOverlay);
+                y -= maxTabHeight - tabRunOverlay;
               else
-                y += (maxTabHeight - tabRunOverlay);
+                y += maxTabHeight - tabRunOverlay;
             }
           else
             {
@@ -508,9 +508,9 @@
                   padTabRun(tabPlacement, start, end, breakAt);
                 }
               if (tabPlacement == RIGHT)
-                x -= (maxTabWidth - tabRunOverlay);
+                x -= maxTabWidth - tabRunOverlay;
               else
-                x += (maxTabWidth - tabRunOverlay);
+                x += maxTabWidth - tabRunOverlay;
               
             }
         }
@@ -1818,7 +1818,7 @@
           next = tabRuns[0];
         else
           next = tabRuns[i + 1];
-        int end = (next != 0 ? next - 1 : tabCount - 1);
+        int end = next != 0 ? next - 1 : tabCount - 1;
         for (int j = start; j <= end; ++j)
           {
             if (j != selectedIndex)
@@ -2194,7 +2194,7 @@
     {
     case LEFT:
       x += calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth);
-      w -= (x - insets.left);
+      w -= x - insets.left;
       break;
     case RIGHT:
       w -= calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth);
@@ -2205,7 +2205,7 @@
     case TOP:
     default:
       y += calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight);
-      h -= (y - insets.top);
+      h -= y - insets.top;
     }
 
     // Fill background if necessary.
@@ -3015,7 +3015,7 @@
   {
     int currRun = getRunForTab(tabCount, tabIndex);
     int offset;
-    int nextRun = (forward) ? getNextTabRun(currRun) : getPreviousTabRun(currRun);
+    int nextRun = forward ? getNextTabRun(currRun) : getPreviousTabRun(currRun);
     if (tabPlacement == SwingConstants.TOP
         || tabPlacement == SwingConstants.BOTTOM)
       offset = rects[lastTabInRun(tabCount, nextRun)].y
Index: javax/swing/plaf/basic/BasicTextAreaUI.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/plaf/basic/BasicTextAreaUI.java,v
retrieving revision 1.8
diff -u -r1.8 BasicTextAreaUI.java
--- javax/swing/plaf/basic/BasicTextAreaUI.java	20 Apr 2006 19:21:08 -0000	1.8
+++ javax/swing/plaf/basic/BasicTextAreaUI.java	1 Jun 2006 05:11:33 -0000
@@ -73,7 +73,7 @@
    */
   public View create(Element elem)
   {
-    JTextArea comp = (JTextArea)getComponent();
+    JTextArea comp = (JTextArea) getComponent();
     if (comp.getLineWrap())
       {
         if (comp.getWrapStyleWord())
@@ -105,7 +105,7 @@
    */
   protected void propertyChange(PropertyChangeEvent ev)
   {
-    JTextArea comp = (JTextArea)getComponent();
+    JTextArea comp = (JTextArea) getComponent();
     if (ev.getPropertyName() == "lineWrap"
         || ev.getPropertyName() == "wrapStyleWord")
       {


More information about the Classpath-patches mailing list