< prev index next >

src/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.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>

@@ -140,13 +140,13 @@
     private Insets currentPadInsets = new Insets(0,0,0,0);
     private Insets currentTabAreaInsets = new Insets(0,0,0,0);
 
     private Component visibleComponent;
     // PENDING(api): See comment for ContainerHandler
-    private Vector htmlViews;
+    private Vector<View> htmlViews;
 
-    private Hashtable mnemonicToIndexMap;
+    private Hashtable<Integer, Integer> mnemonicToIndexMap;
 
     /**
      * InputMap used for mnemonics. Only non-null if the JTabbedPane has
      * mnemonics associated with it. Lazily created in initMnemonics.
      */

@@ -552,11 +552,11 @@
 
     /**
      * Installs the state needed for mnemonics.
      */
     private void initMnemonics() {
-        mnemonicToIndexMap = new Hashtable();
+        mnemonicToIndexMap = new Hashtable<Integer, Integer>();
         mnemonicInputMap = new ComponentInputMapUIResource(tabPane);
         mnemonicInputMap.setParent(SwingUtilities.getUIInputMap(tabPane,
                               JComponent.WHEN_IN_FOCUSED_WINDOW));
         SwingUtilities.replaceUIInputMap(tabPane,
                               JComponent.WHEN_IN_FOCUSED_WINDOW,

@@ -915,14 +915,14 @@
     private static int xCropLen[] = {1,1,0,0,1,1,2,2};
     private static int yCropLen[] = {0,3,3,6,6,9,9,12};
     private static final int CROP_SEGMENT = 12;
 
     private static Polygon createCroppedTabShape(int tabPlacement, Rectangle tabRect, int cropline) {
-        int rlen = 0;
-        int start = 0;
-        int end = 0;
-        int ostart = 0;
+        int rlen;
+        int start;
+        int end;
+        int ostart;
 
         switch(tabPlacement) {
           case LEFT:
           case RIGHT:
               rlen = tabRect.width;

@@ -1020,11 +1020,11 @@
         View v = getTextViewForTab(tabIndex);
         if (v != null) {
             tabPane.putClientProperty("html", v);
         }
 
-        SwingUtilities.layoutCompoundLabel((JComponent) tabPane,
+        SwingUtilities.layoutCompoundLabel(tabPane,
                                            metrics, title, icon,
                                            SwingUtilities.CENTER,
                                            SwingUtilities.CENTER,
                                            SwingUtilities.CENTER,
                                            SwingUtilities.TRAILING,

@@ -1700,11 +1700,11 @@
      *
      * @since 1.4
      */
     protected View getTextViewForTab(int tabIndex) {
         if (htmlViews != null) {
-            return (View)htmlViews.elementAt(tabIndex);
+            return htmlViews.elementAt(tabIndex);
         }
         return null;
     }
 
     protected int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight) {

@@ -2236,12 +2236,11 @@
                 if (command != null && command.length() > 0) {
                     int mnemonic = (int)e.getActionCommand().charAt(0);
                     if (mnemonic >= 'a' && mnemonic <='z') {
                         mnemonic  -= ('a' - 'A');
                     }
-                    Integer index = (Integer)ui.mnemonicToIndexMap.
-                                 get(new Integer(mnemonic));
+                    Integer index = ui.mnemonicToIndexMap.get(Integer.valueOf(mnemonic));
                     if (index != null && pane.isEnabledAt(index.intValue())) {
                         pane.setSelectedIndex(index.intValue());
                     }
                 }
             }

@@ -2298,12 +2297,11 @@
             // child in each dimension
             //
             for (int i = 0; i < tabPane.getTabCount(); i++) {
                 Component component = tabPane.getComponentAt(i);
                 if (component != null) {
-                    Dimension size = zeroSize;
-                    size = minimum? component.getMinimumSize() :
+                    Dimension size = minimum ? component.getMinimumSize() :
                                 component.getPreferredSize();
 
                     if (size != null) {
                         cHeight = Math.max(size.height, cHeight);
                         cWidth = Math.max(size.width, cWidth);

@@ -2311,11 +2309,11 @@
                 }
             }
             // Add content border insets to minimum size
             width += cWidth;
             height += cHeight;
-            int tabExtent = 0;
+            int tabExtent;
 
             // Calculate how much space the tabs will need, based on the
             // minimum size required to display largest child + content border
             //
             switch(tabPlacement) {

@@ -3149,11 +3147,11 @@
             Dimension size = tabPane.getSize();
             Insets insets = tabPane.getInsets();
             Insets tabAreaInsets = getTabAreaInsets(tabPlacement);
             int fontHeight = metrics.getHeight();
             int selectedIndex = tabPane.getSelectedIndex();
-            int i, j;
+            int i;
             boolean verticalTabRuns = (tabPlacement == LEFT || tabPlacement == RIGHT);
             boolean leftToRight = BasicGraphicsUtils.isLeftToRight(tabPane);
             int x = tabAreaInsets.left;
             int y = tabAreaInsets.top;
             int totalWidth = 0;

@@ -3439,14 +3437,14 @@
                 }
             }
         }
 
         public String toString() {
-            return new String("viewport.viewSize="+viewport.getViewSize()+"\n"+
+            return "viewport.viewSize=" + viewport.getViewSize() + "\n" +
                               "viewport.viewRectangle="+viewport.getViewRect()+"\n"+
                               "leadingTabIndex="+leadingTabIndex+"\n"+
-                              "tabViewPosition="+tabViewPosition);
+                              "tabViewPosition=" + tabViewPosition;
         }
 
     }
 
     private class ScrollableTabViewport extends JViewport implements UIResource {

@@ -3794,12 +3792,12 @@
         public void focusLost(FocusEvent e) {
             getHandler().focusLost(e);
         }
     }
 
-    private Vector createHTMLVector() {
-        Vector htmlViews = new Vector();
+    private Vector<View> createHTMLVector() {
+        Vector<View> htmlViews = new Vector<View>();
         int count = tabPane.getTabCount();
         if (count>0) {
             for (int i=0 ; i<count; i++) {
                 String title = tabPane.getTitleAt(i);
                 if (BasicHTML.isHTMLString(title)) {
< prev index next >