Skip to content

Commit

Permalink
Add docs to JSplitButton.
Browse files Browse the repository at this point in the history
  • Loading branch information
weisJ committed Oct 27, 2020
1 parent e6863ca commit fb99265
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ public JSplitButton(final String text, final Icon icon) {
super(text, icon);
}

/**
* Get the number of currently installed action listened.
*
* @return the number of action listeners installed.
*/
public int getActionCount() {
return listenerList.getListenerCount(ActionListener.class);
}
Expand All @@ -99,22 +104,32 @@ public void removeActionListener(final ActionListener l) {
firePropertyChange(KEY_ACTION_REMOVED, l, null);
}

/**
* Get the current action menu. If no menu is currently installed an empty one will be created.
*
* @return the action menu.
*/
public JPopupMenu getActionMenu() {
if (actionMenu == null) {
actionMenu = new JPopupMenu();
}
return actionMenu;
}

/**
* Set the action menu.
*
* @param actionMenu the new action menu.
*/
public void setActionMenu(final JPopupMenu actionMenu) {
this.actionMenu = actionMenu;
}

@Override
public void updateUI() {
super.updateUI();
if (actionMenu != null) {
SwingUtilities.updateComponentTreeUI(actionMenu);
}
}

public void setActionMenu(final JPopupMenu actionMenu) {
this.actionMenu = actionMenu;
}
}

0 comments on commit fb99265

Please sign in to comment.