< prev index next >

src/demo/share/jfc/SwingSet2/ButtonDemo.java

Print this page

        

@@ -59,16 +59,16 @@
     JPanel buttonPanel = new JPanel();
     JPanel checkboxPanel = new JPanel();
     JPanel radioButtonPanel = new JPanel();
     JPanel toggleButtonPanel = new JPanel();
 
-    Vector buttons = new Vector();
-    Vector checkboxes = new Vector();
-    Vector radiobuttons = new Vector();
-    Vector togglebuttons = new Vector();
+    Vector<Component> buttons = new Vector<>();
+    Vector<Component> checkboxes = new Vector<>();
+    Vector<Component> radiobuttons = new Vector<>();
+    Vector<Component> togglebuttons = new Vector<>();
 
-    Vector currentControls = buttons;
+    Vector<Component> currentControls = buttons;
 
     JButton button;
     JCheckBox check;
     JRadioButton radio;
     JToggleButton toggle;

@@ -464,34 +464,34 @@
                 public void itemStateChanged(ItemEvent e) {
                     JCheckBox cb = (JCheckBox) e.getSource();
                     String command = cb.getActionCommand();
                     if(command == "Enabled") {
                         for(int i = 0; i < currentControls.size(); i++) {
-                            c = (Component) currentControls.elementAt(i);
+                            c = currentControls.elementAt(i);
                             c.setEnabled(cb.isSelected());
                             c.invalidate();
                         }
                     } else if(command == "PaintBorder") {
-                        c = (Component) currentControls.elementAt(0);
+                        c = currentControls.elementAt(0);
                         if(c instanceof AbstractButton) {
                             for(int i = 0; i < currentControls.size(); i++) {
                                 b = (AbstractButton) currentControls.elementAt(i);
                                 b.setBorderPainted(cb.isSelected());
                                 b.invalidate();
                             }
                         }
                     } else if(command == "PaintFocus") {
-                        c = (Component) currentControls.elementAt(0);
+                        c = currentControls.elementAt(0);
                         if(c instanceof AbstractButton) {
                             for(int i = 0; i < currentControls.size(); i++) {
                                 b = (AbstractButton) currentControls.elementAt(i);
                                 b.setFocusPainted(cb.isSelected());
                                 b.invalidate();
                             }
                         }
                     } else if(command == "ContentFilled") {
-                        c = (Component) currentControls.elementAt(0);
+                        c = currentControls.elementAt(0);
                         if(c instanceof AbstractButton) {
                             for(int i = 0; i < currentControls.size(); i++) {
                                 b = (AbstractButton) currentControls.elementAt(i);
                                 b.setContentAreaFilled(cb.isSelected());
                                 b.invalidate();

@@ -547,9 +547,9 @@
         } else {
             currentControls = togglebuttons;
         }
     }
 
-    public Vector getCurrentControls() {
+    public Vector<Component> getCurrentControls() {
         return currentControls;
     }
 }
< prev index next >