我们可以使用一个JInternalFame https://docs.oracle.com/javase/tutorial/uiswing/components/internalframe.html主框架中有一个按钮?该框架包含一个JDesktopPane
, 当然。该按钮应该打开JInternalFrame
How?
我不知道如何放置JButton
直接在一个JDesktopPane
,但您可以使用菜单项来创建和选择JInternalFrame
。在这个example http://groups.google.com/group/comp.lang.java.programmer/msg/2e1b14bcad9bd7fa,每个菜单项使用一个Action https://docs.oracle.com/javase/tutorial/uiswing/misc/action.html定义在JInternalFrame
选择相应的框架。
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; }
}
附录:正如 @camickr 所建议的,技术上可以将JButton
直接在一个JDesktopPane
,但在实践中可能很难使用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)