I do not know how to place JButtondirectly on JDesktopPane, but you can use the menu items to create and select JInternalFrame. In this example, each menu item uses the Actionone defined in JInternalFrameto select the corresponding frame.
class MyFrame extends JInternalFrame {
private Action action;
MyFrame(JDesktopPane desktop, String name, int offset) {
…
action = new AbstractAction(name) {
@Override
public void actionPerformed(ActionEvent ae) {
try {
MyFrame.this.setSelected(true);
} catch (PropertyVetoException e) {
e.printStackTrace();
}
}
};
}
public Action getAction() { return action; }
}
Addendum: as @camickr suggests, it can technically be put JButtondirectly on JDesktopPane, but it can be difficult to put into practice.
source
share