- buttonClicked(e)
- splitButtonClicked(e)
To handle these events you need to subscribe to SplitButtonActionListener.
Screenshots:


Using the Control:
//first instantiate the control
JSplitButton splitButton = new JSplitButton();
//register for listener
splitButton.addSplitButtonActionListener(new SplitButtonActionListener() {
public void buttonClicked(ActionEvent e) {
System.out.println("Button Clicked");
}
public void splitButtonClicked(ActionEvent e) {
System.out.println("Split Part licked");
}
});
//add popup menu
splitButton.add(popupMenu);
//add this control to panel
panel.add(splitButton);
NetBeans users can also add the control to the NetBeans palette.
Known Issue:
The 'button part' of the splitbutton is being drawn without the border??? and this is only happening in CDE/Motif and Metal Look and Feels.GTK+ and nimbus works perfect.(See Screenshot below) No Idea why? if anybody could point out the mistake that'd be nice.
The source for this control can be downloaded from google-code.

No comments:
Post a Comment