Hello,
I'm trying to write a JFrame with a JInternalFrame. I have JMenuBar and JMenuItem when I click it,it should open new JInternalFrame.
The problem is when I use JDesktopPane it overwrites my mainFraim.getContentPane(). And when I try to add JDesktopPane into
mainFraim.getContentPane().add(JDesktopPane) it doesnt work can you pls help me to find why? or try to figure out how to add it into my mainFrame.
desk = new JDesktopPane(); frmTitsFireCrisis.getContentPane().add(desk,BorderLayout.CENTER); JMenuItem Sim = new JMenuItem("Simlation of the crisis"); // Sim.setAction(action); Sim.setMnemonic('S'); Sim.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,0)); Sim.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ JInternalFrame iT = new JInternalFrame("Crisis"); iT.setVisible(true); iT.setResizable(true); iT.setClosable(true); iT.setMaximizable(true); iT.setIconifiable(true); iT.setBounds(200,200,200,200); //frmTitsFireCrisis.getContentPane().add(iT); // iT.getContentPane().add(new JButton("but")); desk.add(iT); try{ iT.setSelected(true); } catch (Exception ex){ ex.printStackTrace(); } } });