Search in sources :

Example 1 with DefaultButtonModel

use of javax.swing.DefaultButtonModel in project jdk8u_jdk by JetBrains.

the class bug7189299 method verifySingleDefaultButtonModelListener.

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.");
    }
}
Also used : DefaultButtonModel(javax.swing.DefaultButtonModel) ActionListener(java.awt.event.ActionListener) HTMLEditorKit(javax.swing.text.html.HTMLEditorKit) StyleContext(javax.swing.text.StyleContext)

Aggregations

ActionListener (java.awt.event.ActionListener)1 DefaultButtonModel (javax.swing.DefaultButtonModel)1 StyleContext (javax.swing.text.StyleContext)1 HTMLEditorKit (javax.swing.text.html.HTMLEditorKit)1