java - Creating a popup window on button click using JPanel from another JPanel -
i using netbeans create gui tool working on. tools contents contained in class extends jpanel , has button. when click button, want window pop have additional buttons , options, contents of defined in class extends jpanel. how can accomplish this?
simplified code of main class. removed code not important problem:
public class firstpanel extends jpanel { private jbutton mybutton; public firstpanel() { mybutton = new jbutton("button"); mybutton.addactionlistener(new actionlistener() { @override public void actionperformed(actionevent ae) { // } }); } }
and second class similar, , in charge of handling of buttons , such. how can accomplish this?
see how use menus: bringing popup menu correct way handle in cross-platform mouselistener
. more simply, use setcomponentpopupmenu()
, shown here. in either case, note use of action
encapsulate desired functionality.
Comments
Post a Comment