posted 23 years ago
Has anybody ever figured out how to build an MDI interface with a Windows menu? I've seen an example on JavaWorld (mditest) but it doesn't sync the Windows menu with the JInternalFrames. I've tried this:
JMenu fileMenu = new JMenu("File");
fileMenu.setMnemonic('f');
mb.add(fileMenu);
JMenuItem newItem = new JMenuItem("New");
newItem.setMnemonic('n');
ActionListener lst = new ActionListener() {
public void actionPerformed(ActionEvent e) {
JInternalFrame jif = new JInternalFrame("Document" + ++frameCount, true, true,
true, true);
Dimension d = desktop.getSize();
jif.setBounds(frameCount * 25,frameCount * 25, d.width/2, d.height/2);
jif.show();
desktop.add(jif);
desktop.moveToFront(jif);
if (windowMenu == null) {
windowMenu = new JMenu("Window");
windowMenu.setMnemonic('w');
mb.add(windowMenu);
}
JMenuItem windowItem = new JMenuItem(frameCount + ". Document" + frameCount);
windowMenu.add(windowItem);
}
};
newItem.addActionListener(lst);
fileMenu.add(newItem);
but I can't figure out how to put a listener or action on the JMenuItem that ties it to a particular JInternalFrame.
Thanks in advance.