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.");
}
}
Aggregations