< prev index next >

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

Print this page

        

*** 59,74 **** 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 currentControls = buttons; JButton button; JCheckBox check; JRadioButton radio; JToggleButton toggle; --- 59,74 ---- JPanel buttonPanel = new JPanel(); JPanel checkboxPanel = new JPanel(); JPanel radioButtonPanel = new JPanel(); JPanel toggleButtonPanel = new JPanel(); ! Vector<Component> buttons = new Vector<>(); ! Vector<Component> checkboxes = new Vector<>(); ! Vector<Component> radiobuttons = new Vector<>(); ! Vector<Component> togglebuttons = new Vector<>(); ! Vector<Component> currentControls = buttons; JButton button; JCheckBox check; JRadioButton radio; JToggleButton toggle;
*** 464,497 **** 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.setEnabled(cb.isSelected()); c.invalidate(); } } else if(command == "PaintBorder") { ! c = (Component) 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); 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); if(c instanceof AbstractButton) { for(int i = 0; i < currentControls.size(); i++) { b = (AbstractButton) currentControls.elementAt(i); b.setContentAreaFilled(cb.isSelected()); b.invalidate(); --- 464,497 ---- 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 = currentControls.elementAt(i); c.setEnabled(cb.isSelected()); c.invalidate(); } } else if(command == "PaintBorder") { ! 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 = 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 = 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,555 **** } else { currentControls = togglebuttons; } } ! public Vector getCurrentControls() { return currentControls; } } --- 547,555 ---- } else { currentControls = togglebuttons; } } ! public Vector<Component> getCurrentControls() { return currentControls; } }
< prev index next >