javax.swing.DefaultButtonModel Java Examples

The following examples show how to use javax.swing.DefaultButtonModel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DropdownButton.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
Button(String text, Icon icon) {
    super(text, icon);
    
    // See GenericToolbar.addImpl()
    putClientProperty("MetalListener", new Object()); // NOI18N
    
    if (UIUtils.isAquaLookAndFeel())
        putClientProperty("JComponent.sizeVariant", "regular"); // NOI18N
    
    setModel(new DefaultButtonModel() {
        public boolean isRollover() {
            return super.isRollover() || (isEnabled() && (popup != null && popup.getModel().isRollover()));
        }
        public boolean isPressed() {
            return pushed || super.isPressed();
        }
        public boolean isArmed() {
            return pushed || super.isArmed();
        }
    });
    
    setHorizontalAlignment(LEADING);
    setDefaultCapable(false);
}
 
Example #2
Source File: DropdownButton.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
Popup() {
    super(" "); // NOI18N
    
    // See GenericToolbar.addImpl()
    putClientProperty("MetalListener", new Object()); // NOI18N
    
    setModel(new DefaultButtonModel() {
        public boolean isRollover() {
            return super.isRollover() || pushed;
        }
    });
    
    setHorizontalAlignment(LEADING);
    setDefaultCapable(false);
    
    getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, false), NO_ACTION);
    getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, true), NO_ACTION);
}
 
Example #3
Source File: DocumentSwitcherTable.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private JButton createCloseButton() {
    JButton res = CloseButtonFactory.createBigCloseButton();
    res.setModel( new DefaultButtonModel() {
        @Override
        public boolean isRollover() {
            return inCloseButtonRect;
        }
    });
    //allow third party look and feels to provide their own icons
    Icon defaultIcon = UIManager.getIcon( "nb.popupswitcher.closebutton.defaultIcon" ); //NOI18N
    if( null != defaultIcon )
        res.setIcon( defaultIcon );
    Icon rolloverIcon = UIManager.getIcon( "nb.popupswitcher.closebutton.rolloverIcon" ); //NOI18N
    if( null != rolloverIcon )
        res.setRolloverIcon( rolloverIcon );
    return res;
}
 
Example #4
Source File: MnemonicsTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testSetLocalizedTextWithModel() throws Exception {
    ButtonModel m = new DefaultButtonModel();
    JButton b = new JButton();
    Mnemonics.setLocalizedText(b, "Hello &There");
    assertEquals("Hello There", b.getText());
    if( Mnemonics.isAquaLF() ) {
        assertEquals(0, b.getMnemonic());
        assertEquals(-1, b.getDisplayedMnemonicIndex());
    } else {
        assertEquals('T', b.getMnemonic());
        assertEquals(6, b.getDisplayedMnemonicIndex());
    }
    b.setModel(m);
    assertEquals("Hello There", b.getText());
    if( Mnemonics.isAquaLF() ) {
        assertEquals(0, b.getMnemonic());
        assertEquals(-1, b.getDisplayedMnemonicIndex());
    } else {
        assertEquals('T', b.getMnemonic());
        assertEquals(6, b.getDisplayedMnemonicIndex());
    }
}
 
Example #5
Source File: WhylineButton.java    From whyline with MIT License 6 votes vote down vote up
public WhylineButton(Action abstractAction, String tooltip) {
	
	super(abstractAction);

	setFont(UI.getMediumFont());
	setFocusable(false);
	setOpaque(false);
	setToolTipText(tooltip);
	setContentAreaFilled(true);
	setRolloverEnabled(true);
	
	// Hack so that toolbar buttons in MetalLookAndFeel always show their background.
	setModel(new DefaultButtonModel() {
		public boolean isRollover() { return true; }
	});
	
}
 
Example #6
Source File: ProfilerPopup.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
public Component getDefaultComponent(Container aContainer) {
    Component c = getFirstComponent(aContainer);
    
    if (c instanceof AbstractButton) {
        ButtonModel bm = ((AbstractButton)c).getModel();
        if (bm instanceof DefaultButtonModel) {
            ButtonGroup bg = ((DefaultButtonModel)bm).getGroup();
            Enumeration<AbstractButton> en = bg == null ? null : bg.getElements();
            while (en != null && en.hasMoreElements()) {
                AbstractButton ab = en.nextElement();
                if (ab.isSelected()) return ab;
            }
        }
    }
    
    return c;
}
 
Example #7
Source File: DropdownButton.java    From netbeans with Apache License 2.0 6 votes vote down vote up
Button(String text, Icon icon) {
    super(text, icon);
    
    // See GenericToolbar.addImpl()
    putClientProperty("MetalListener", new Object()); // NOI18N
    
    if (UIUtils.isAquaLookAndFeel())
        putClientProperty("JComponent.sizeVariant", "regular"); // NOI18N
    
    setModel(new DefaultButtonModel() {
        public boolean isRollover() {
            return super.isRollover() || (isEnabled() && (popup != null && popup.getModel().isRollover()));
        }
        public boolean isPressed() {
            return pushed || super.isPressed();
        }
        public boolean isArmed() {
            return pushed || super.isArmed();
        }
    });
    
    setHorizontalAlignment(LEADING);
    setDefaultCapable(false);
}
 
Example #8
Source File: DropdownButton.java    From netbeans with Apache License 2.0 6 votes vote down vote up
Popup() {
    super(" "); // NOI18N
    
    // See GenericToolbar.addImpl()
    putClientProperty("MetalListener", new Object()); // NOI18N
    
    setModel(new DefaultButtonModel() {
        public boolean isRollover() {
            return super.isRollover() || pushed;
        }
    });
    
    setHorizontalAlignment(LEADING);
    setDefaultCapable(false);
    
    getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, false), NO_ACTION);
    getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, true), NO_ACTION);
}
 
Example #9
Source File: ProfilerPopup.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public Component getDefaultComponent(Container aContainer) {
    Component c = getFirstComponent(aContainer);
    
    if (c instanceof AbstractButton) {
        ButtonModel bm = ((AbstractButton)c).getModel();
        if (bm instanceof DefaultButtonModel) {
            ButtonGroup bg = ((DefaultButtonModel)bm).getGroup();
            Enumeration<AbstractButton> en = bg == null ? null : bg.getElements();
            while (en != null && en.hasMoreElements()) {
                AbstractButton ab = en.nextElement();
                if (ab.isSelected()) return ab;
            }
        }
    }
    
    return c;
}
 
Example #10
Source File: ButtonBuilders.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
protected void setupInstance(DefaultButtonModel instance) {
    super.setupInstance(instance);
    
    instance.setArmed((stateMask & DefaultButtonModel.ARMED) != 0);
    instance.setSelected((stateMask & DefaultButtonModel.SELECTED) != 0);
    instance.setEnabled((stateMask & DefaultButtonModel.ENABLED) != 0);
    instance.setPressed((stateMask & DefaultButtonModel.PRESSED) != 0);
    instance.setRollover((stateMask & DefaultButtonModel.ROLLOVER) != 0);
}
 
Example #11
Source File: bug7189299.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void verifySingleDefaultButtonModelListener() {
    HTMLEditorKit htmlEditorKit = (HTMLEditorKit) html.getEditorKit();
    StyleContext.NamedStyle style = ((StyleContext.NamedStyle) htmlEditorKit
            .getInputAttributes());
    DefaultButtonModel model = ((DefaultButtonModel) style
            .getAttribute(StyleConstants.ModelAttribute));
    ActionListener[] listeners = model.getActionListeners();
    int actionListenerNum = listeners.length;
    if (actionListenerNum != 1) {
        throw new RuntimeException(
                "Expected single ActionListener object registered with "
                + "DefaultButtonModel; found " + actionListenerNum
                + " listeners registered.");
    }

    int changeListenerNum = model.getChangeListeners().length;
    if (changeListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ChangeListener object registered "
                + "with DefaultButtonModel; found " + changeListenerNum
                + " listeners registered.");
    }
    int itemListenerNum = model.getItemListeners().length;
    if (itemListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ItemListener object registered "
                + "with DefaultButtonModel; found " + itemListenerNum
                + " listeners registered.");
    }
}
 
Example #12
Source File: DisplayAreaSupport.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
TabButton(String text, String description) {
    super(text);
    setModel(new DefaultButtonModel() {
        public boolean isPressed() { return false; }
    });
    setOpaque(false);
    setFocusPainted(false);
    setBorderPainted(false);
    setContentAreaFilled(false);
    setBorder(BorderFactory.createEmptyBorder(TABBUTTON_MARGIN_TOP, TABBUTTON_MARGIN_LEFT, TABBUTTON_MARGIN_BOTTOM, TABBUTTON_MARGIN_RIGHT));
    setToolTipText(description);
}
 
Example #13
Source File: bug7189299.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void verifySingleDefaultButtonModelListener() {
    HTMLEditorKit htmlEditorKit = (HTMLEditorKit) html.getEditorKit();
    StyleContext.NamedStyle style = ((StyleContext.NamedStyle) htmlEditorKit
            .getInputAttributes());
    DefaultButtonModel model = ((DefaultButtonModel) style
            .getAttribute(StyleConstants.ModelAttribute));
    ActionListener[] listeners = model.getActionListeners();
    int actionListenerNum = listeners.length;
    if (actionListenerNum != 1) {
        throw new RuntimeException(
                "Expected single ActionListener object registered with "
                + "DefaultButtonModel; found " + actionListenerNum
                + " listeners registered.");
    }

    int changeListenerNum = model.getChangeListeners().length;
    if (changeListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ChangeListener object registered "
                + "with DefaultButtonModel; found " + changeListenerNum
                + " listeners registered.");
    }
    int itemListenerNum = model.getItemListeners().length;
    if (itemListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ItemListener object registered "
                + "with DefaultButtonModel; found " + itemListenerNum
                + " listeners registered.");
    }
}
 
Example #14
Source File: bug7189299.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void verifySingleDefaultButtonModelListener() {
    HTMLEditorKit htmlEditorKit = (HTMLEditorKit) html.getEditorKit();
    StyleContext.NamedStyle style = ((StyleContext.NamedStyle) htmlEditorKit
            .getInputAttributes());
    DefaultButtonModel model = ((DefaultButtonModel) style
            .getAttribute(StyleConstants.ModelAttribute));
    ActionListener[] listeners = model.getActionListeners();
    int actionListenerNum = listeners.length;
    if (actionListenerNum != 1) {
        throw new RuntimeException(
                "Expected single ActionListener object registered with "
                + "DefaultButtonModel; found " + actionListenerNum
                + " listeners registered.");
    }

    int changeListenerNum = model.getChangeListeners().length;
    if (changeListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ChangeListener object registered "
                + "with DefaultButtonModel; found " + changeListenerNum
                + " listeners registered.");
    }
    int itemListenerNum = model.getItemListeners().length;
    if (itemListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ItemListener object registered "
                + "with DefaultButtonModel; found " + itemListenerNum
                + " listeners registered.");
    }
}
 
Example #15
Source File: ColorChooserButton.java    From netbeans-mmd-plugin with Apache License 2.0 5 votes vote down vote up
public ColorChooserButton() {
  super();

  final ColorChooserButton theButtonInstance = this;

  this.setModel(new DefaultButtonModel() {
    private static final long serialVersionUID = 3109256773218160485L;

    @Override
    protected void fireActionPerformed(ActionEvent e) {
      final Window ownerWindow = SwingUtilities.getWindowAncestor(theButtonInstance);

      final ColorChooser colorChooser = new ColorChooser(usedColors, value);

      if (DialogProviderManager.getInstance().getDialogProvider()
              .msgOkCancel(ownerWindow == null ? Main.getApplicationFrame() : ownerWindow,
                      String.format(UiUtils.BUNDLE.getString("ColorChoosingButton.dialogTitle"),
                              getText()),
                      colorChooser.getPanel())) {
        final Color selectedColor = colorChooser.getColor();
        if (selectedColor != null) {
          setValue(selectedColor);
          lastResultOk = true;
        } else {
          lastResultOk = false;
        }

        super.fireActionPerformed(e);
      }
    }
  });

  setValue(Color.BLACK);
}
 
Example #16
Source File: ColorChooserButton.java    From netbeans-mmd-plugin with Apache License 2.0 5 votes vote down vote up
public ColorChooserButton(@Nullable final DialogProvider dialogProvider) {
  super();

  this.setHorizontalAlignment(SwingConstants.LEFT);

  this.setModel(new DefaultButtonModel() {
    private static final long serialVersionUID = 3109256773218160485L;

    @Override
    protected void fireActionPerformed(ActionEvent e) {
      final Window ownerWindow = SwingUtilities.getWindowAncestor(ColorChooserButton.this);

      final com.igormaznitsa.mindmap.swing.colorpicker.ColorChooser colorChooser = new com.igormaznitsa.mindmap.swing.colorpicker.ColorChooser(usedColors, value);

      final String title = String.format(BUNDLE.getString("ColorChoosingButton.dialogTitle"), getText());
      final boolean result;

      if (dialogProvider == null) {
        result = JOptionPane.showConfirmDialog(ownerWindow, colorChooser.getPanel(), title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null) == JOptionPane.OK_OPTION;
      } else {
        result = dialogProvider.msgOkCancel(ColorChooserButton.this, title, colorChooser.getPanel());
      }

      if (result) {
        setValue(colorChooser.getColor());
        lastResultOk = true;
      } else {
        lastResultOk = false;
      }

      super.fireActionPerformed(e);
    }

  });

  setValue(Color.BLACK);
}
 
Example #17
Source File: ColorChooserButton.java    From netbeans-mmd-plugin with Apache License 2.0 5 votes vote down vote up
public ColorChooserButton() {
  super();

  this.setModel(new DefaultButtonModel() {
    private static final long serialVersionUID = 3109256773218160485L;

    @Override
    protected void fireActionPerformed(@Nonnull final ActionEvent e) {
      final Window window = SwingUtilities.windowForComponent(ColorChooserButton.this);

      final ColorChooser colorChooser = new ColorChooser(usedColors, value);
      final DialogProvider provider = DialogProviderManager.getInstance().getDialogProvider();
      final String title = String.format(java.util.ResourceBundle.getBundle("com/igormaznitsa/nbmindmap/i18n/Bundle")
              .getString("ColorChoosingButton.dialogTitle"), getText());

      if (provider.msgOkCancel(window, title, colorChooser.getPanel())) {
        setValue(colorChooser.getColor());
        lastResultOk = true;
      } else {
        lastResultOk = false;
      }

      super.fireActionPerformed(e);
    }
  });

  setValue(Color.BLACK);
}
 
Example #18
Source File: bug7189299.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void verifySingleDefaultButtonModelListener() {
    HTMLEditorKit htmlEditorKit = (HTMLEditorKit) html.getEditorKit();
    StyleContext.NamedStyle style = ((StyleContext.NamedStyle) htmlEditorKit
            .getInputAttributes());
    DefaultButtonModel model = ((DefaultButtonModel) style
            .getAttribute(StyleConstants.ModelAttribute));
    ActionListener[] listeners = model.getActionListeners();
    int actionListenerNum = listeners.length;
    if (actionListenerNum != 1) {
        throw new RuntimeException(
                "Expected single ActionListener object registered with "
                + "DefaultButtonModel; found " + actionListenerNum
                + " listeners registered.");
    }

    int changeListenerNum = model.getChangeListeners().length;
    if (changeListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ChangeListener object registered "
                + "with DefaultButtonModel; found " + changeListenerNum
                + " listeners registered.");
    }
    int itemListenerNum = model.getItemListeners().length;
    if (itemListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ItemListener object registered "
                + "with DefaultButtonModel; found " + itemListenerNum
                + " listeners registered.");
    }
}
 
Example #19
Source File: bug7189299.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void verifySingleDefaultButtonModelListener() {
    HTMLEditorKit htmlEditorKit = (HTMLEditorKit) html.getEditorKit();
    StyleContext.NamedStyle style = ((StyleContext.NamedStyle) htmlEditorKit
            .getInputAttributes());
    DefaultButtonModel model = ((DefaultButtonModel) style
            .getAttribute(StyleConstants.ModelAttribute));
    ActionListener[] listeners = model.getActionListeners();
    int actionListenerNum = listeners.length;
    if (actionListenerNum != 1) {
        throw new RuntimeException(
                "Expected single ActionListener object registered with "
                + "DefaultButtonModel; found " + actionListenerNum
                + " listeners registered.");
    }

    int changeListenerNum = model.getChangeListeners().length;
    if (changeListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ChangeListener object registered "
                + "with DefaultButtonModel; found " + changeListenerNum
                + " listeners registered.");
    }
    int itemListenerNum = model.getItemListeners().length;
    if (itemListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ItemListener object registered "
                + "with DefaultButtonModel; found " + itemListenerNum
                + " listeners registered.");
    }
}
 
Example #20
Source File: UserPreferences.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public static void track(final JRadioButton button) {
  final Preferences prefs = node().node("Buttons");
  boolean selected = prefs.getBoolean(button.getName() + ".selected", button
      .isSelected());
  ((DefaultButtonModel) button.getModel()).getGroup().setSelected(
      button.getModel(), selected);// .setSelected(selected);
  button.addItemListener(new ItemListener() {
    public void itemStateChanged(ItemEvent e) {
      prefs.putBoolean(button.getName() + ".selected", button.isSelected());
    }
  });
}
 
Example #21
Source File: bug7189299.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static void verifySingleDefaultButtonModelListener() {
    HTMLEditorKit htmlEditorKit = (HTMLEditorKit) html.getEditorKit();
    StyleContext.NamedStyle style = ((StyleContext.NamedStyle) htmlEditorKit
            .getInputAttributes());
    DefaultButtonModel model = ((DefaultButtonModel) style
            .getAttribute(StyleConstants.ModelAttribute));
    ActionListener[] listeners = model.getActionListeners();
    int actionListenerNum = listeners.length;
    if (actionListenerNum != 1) {
        throw new RuntimeException(
                "Expected single ActionListener object registered with "
                + "DefaultButtonModel; found " + actionListenerNum
                + " listeners registered.");
    }

    int changeListenerNum = model.getChangeListeners().length;
    if (changeListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ChangeListener object registered "
                + "with DefaultButtonModel; found " + changeListenerNum
                + " listeners registered.");
    }
    int itemListenerNum = model.getItemListeners().length;
    if (itemListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ItemListener object registered "
                + "with DefaultButtonModel; found " + itemListenerNum
                + " listeners registered.");
    }
}
 
Example #22
Source File: bug7189299.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static void verifySingleDefaultButtonModelListener() {
    HTMLEditorKit htmlEditorKit = (HTMLEditorKit) html.getEditorKit();
    StyleContext.NamedStyle style = ((StyleContext.NamedStyle) htmlEditorKit
            .getInputAttributes());
    DefaultButtonModel model = ((DefaultButtonModel) style
            .getAttribute(StyleConstants.ModelAttribute));
    ActionListener[] listeners = model.getActionListeners();
    int actionListenerNum = listeners.length;
    if (actionListenerNum != 1) {
        throw new RuntimeException(
                "Expected single ActionListener object registered with "
                + "DefaultButtonModel; found " + actionListenerNum
                + " listeners registered.");
    }

    int changeListenerNum = model.getChangeListeners().length;
    if (changeListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ChangeListener object registered "
                + "with DefaultButtonModel; found " + changeListenerNum
                + " listeners registered.");
    }
    int itemListenerNum = model.getItemListeners().length;
    if (itemListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ItemListener object registered "
                + "with DefaultButtonModel; found " + itemListenerNum
                + " listeners registered.");
    }
}
 
Example #23
Source File: bug7189299.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void verifySingleDefaultButtonModelListener() {
    HTMLEditorKit htmlEditorKit = (HTMLEditorKit) html.getEditorKit();
    StyleContext.NamedStyle style = ((StyleContext.NamedStyle) htmlEditorKit
            .getInputAttributes());
    DefaultButtonModel model = ((DefaultButtonModel) style
            .getAttribute(StyleConstants.ModelAttribute));
    ActionListener[] listeners = model.getActionListeners();
    int actionListenerNum = listeners.length;
    if (actionListenerNum != 1) {
        throw new RuntimeException(
                "Expected single ActionListener object registered with "
                + "DefaultButtonModel; found " + actionListenerNum
                + " listeners registered.");
    }

    int changeListenerNum = model.getChangeListeners().length;
    if (changeListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ChangeListener object registered "
                + "with DefaultButtonModel; found " + changeListenerNum
                + " listeners registered.");
    }
    int itemListenerNum = model.getItemListeners().length;
    if (itemListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ItemListener object registered "
                + "with DefaultButtonModel; found " + itemListenerNum
                + " listeners registered.");
    }
}
 
Example #24
Source File: bug7189299.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void verifySingleDefaultButtonModelListener() {
    HTMLEditorKit htmlEditorKit = (HTMLEditorKit) html.getEditorKit();
    StyleContext.NamedStyle style = ((StyleContext.NamedStyle) htmlEditorKit
            .getInputAttributes());
    DefaultButtonModel model = ((DefaultButtonModel) style
            .getAttribute(StyleConstants.ModelAttribute));
    ActionListener[] listeners = model.getActionListeners();
    int actionListenerNum = listeners.length;
    if (actionListenerNum != 1) {
        throw new RuntimeException(
                "Expected single ActionListener object registered with "
                + "DefaultButtonModel; found " + actionListenerNum
                + " listeners registered.");
    }

    int changeListenerNum = model.getChangeListeners().length;
    if (changeListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ChangeListener object registered "
                + "with DefaultButtonModel; found " + changeListenerNum
                + " listeners registered.");
    }
    int itemListenerNum = model.getItemListeners().length;
    if (itemListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ItemListener object registered "
                + "with DefaultButtonModel; found " + itemListenerNum
                + " listeners registered.");
    }
}
 
Example #25
Source File: bug7189299.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static void verifySingleDefaultButtonModelListener() {
    HTMLEditorKit htmlEditorKit = (HTMLEditorKit) html.getEditorKit();
    StyleContext.NamedStyle style = ((StyleContext.NamedStyle) htmlEditorKit
            .getInputAttributes());
    DefaultButtonModel model = ((DefaultButtonModel) style
            .getAttribute(StyleConstants.ModelAttribute));
    ActionListener[] listeners = model.getActionListeners();
    int actionListenerNum = listeners.length;
    if (actionListenerNum != 1) {
        throw new RuntimeException(
                "Expected single ActionListener object registered with "
                + "DefaultButtonModel; found " + actionListenerNum
                + " listeners registered.");
    }

    int changeListenerNum = model.getChangeListeners().length;
    if (changeListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ChangeListener object registered "
                + "with DefaultButtonModel; found " + changeListenerNum
                + " listeners registered.");
    }
    int itemListenerNum = model.getItemListeners().length;
    if (itemListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ItemListener object registered "
                + "with DefaultButtonModel; found " + itemListenerNum
                + " listeners registered.");
    }
}
 
Example #26
Source File: ButtonBuilders.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void setupInstance(DefaultButtonModel instance) {
    super.setupInstance(instance);
    
    instance.setArmed((stateMask & DefaultButtonModel.ARMED) != 0);
    instance.setSelected((stateMask & DefaultButtonModel.SELECTED) != 0);
    instance.setEnabled((stateMask & DefaultButtonModel.ENABLED) != 0);
    instance.setPressed((stateMask & DefaultButtonModel.PRESSED) != 0);
    instance.setRollover((stateMask & DefaultButtonModel.ROLLOVER) != 0);
}
 
Example #27
Source File: CustomizerLibraries.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Messages("CTL_AddSimple=&Add...")
public CustomizerLibraries(SingleModuleProperties props, ProjectCustomizer.Category category, @NonNull NbModuleProject p) {
    super(props, CustomizerLibraries.class, category);
    initComponents();
    if (!getProperties().isSuiteComponent()) {
        addLibrary.setVisible(false);
        Mnemonics.setLocalizedText(addDepButton, CTL_AddSimple());
    }
    refresh();
    dependencyList.setCellRenderer(CustomizerComponentFactory.getDependencyCellRenderer(false));
    javaPlatformCombo.setRenderer(JavaPlatformComponentFactory.javaPlatformListCellRenderer());
    removeTokenButton.setEnabled(false);
    wrappedJarsList.setCellRenderer(ClassPathListCellRenderer.createClassPathListRenderer(
            getProperties().getEvaluator(),
            FileUtil.toFileObject(getProperties().getProjectDirectoryFile())));
    DefaultButtonModel dummy = new DefaultButtonModel();
    EditMediator.register(
            p,
            getProperties().getHelper(),
            getProperties().getRefHelper(),
            emListComp,
            dummy,
            dummy,
            dummy,
            removeButton.getModel(),
            dummy,
            dummy,
            editButton.getModel(),
            null,
            null);
    attachListeners();
    pxml = new ProjectXMLManager(p);
}
 
Example #28
Source File: bug7189299.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void verifySingleDefaultButtonModelListener() {
    HTMLEditorKit htmlEditorKit = (HTMLEditorKit) html.getEditorKit();
    StyleContext.NamedStyle style = ((StyleContext.NamedStyle) htmlEditorKit
            .getInputAttributes());
    DefaultButtonModel model = ((DefaultButtonModel) style
            .getAttribute(StyleConstants.ModelAttribute));
    ActionListener[] listeners = model.getActionListeners();
    int actionListenerNum = listeners.length;
    if (actionListenerNum != 1) {
        throw new RuntimeException(
                "Expected single ActionListener object registered with "
                + "DefaultButtonModel; found " + actionListenerNum
                + " listeners registered.");
    }

    int changeListenerNum = model.getChangeListeners().length;
    if (changeListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ChangeListener object registered "
                + "with DefaultButtonModel; found " + changeListenerNum
                + " listeners registered.");
    }
    int itemListenerNum = model.getItemListeners().length;
    if (itemListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ItemListener object registered "
                + "with DefaultButtonModel; found " + itemListenerNum
                + " listeners registered.");
    }
}
 
Example #29
Source File: bug7189299.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static void verifySingleDefaultButtonModelListener() {
    HTMLEditorKit htmlEditorKit = (HTMLEditorKit) html.getEditorKit();
    StyleContext.NamedStyle style = ((StyleContext.NamedStyle) htmlEditorKit
            .getInputAttributes());
    DefaultButtonModel model = ((DefaultButtonModel) style
            .getAttribute(StyleConstants.ModelAttribute));
    ActionListener[] listeners = model.getActionListeners();
    int actionListenerNum = listeners.length;
    if (actionListenerNum != 1) {
        throw new RuntimeException(
                "Expected single ActionListener object registered with "
                + "DefaultButtonModel; found " + actionListenerNum
                + " listeners registered.");
    }

    int changeListenerNum = model.getChangeListeners().length;
    if (changeListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ChangeListener object registered "
                + "with DefaultButtonModel; found " + changeListenerNum
                + " listeners registered.");
    }
    int itemListenerNum = model.getItemListeners().length;
    if (itemListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ItemListener object registered "
                + "with DefaultButtonModel; found " + itemListenerNum
                + " listeners registered.");
    }
}
 
Example #30
Source File: bug7189299.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void verifySingleDefaultButtonModelListener() {
    HTMLEditorKit htmlEditorKit = (HTMLEditorKit) html.getEditorKit();
    StyleContext.NamedStyle style = ((StyleContext.NamedStyle) htmlEditorKit
            .getInputAttributes());
    DefaultButtonModel model = ((DefaultButtonModel) style
            .getAttribute(StyleConstants.ModelAttribute));
    ActionListener[] listeners = model.getActionListeners();
    int actionListenerNum = listeners.length;
    if (actionListenerNum != 1) {
        throw new RuntimeException(
                "Expected single ActionListener object registered with "
                + "DefaultButtonModel; found " + actionListenerNum
                + " listeners registered.");
    }

    int changeListenerNum = model.getChangeListeners().length;
    if (changeListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ChangeListener object registered "
                + "with DefaultButtonModel; found " + changeListenerNum
                + " listeners registered.");
    }
    int itemListenerNum = model.getItemListeners().length;
    if (itemListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ItemListener object registered "
                + "with DefaultButtonModel; found " + itemListenerNum
                + " listeners registered.");
    }
}