Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: JInternalFrame isnt working why

  1. #1
    Member
    Join Date
    Apr 2012
    Posts
    57
    My Mood
    Angelic
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default JInternalFrame isnt working why

    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();
    			}
    			}
    		});


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: JInternalFrame isnt working why

    Please post a small complete program that compiles, executes and shows the problem.

    One possible problem is calling setVisible before the GUI is built. Call it when the GUI is ready to be seen.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. How to add a JInternalFrame within a JTabbedPane
    By Henry518 in forum AWT / Java Swing
    Replies: 0
    Last Post: November 1st, 2011, 03:58 PM
  2. Replies: 1
    Last Post: September 26th, 2011, 07:23 AM
  3. keylistner + applet isnt working
    By brandon95 in forum AWT / Java Swing
    Replies: 3
    Last Post: January 4th, 2011, 07:16 AM
  4. Key Listener not working in jinternalframe
    By furqankhan in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 12th, 2010, 09:48 AM
  5. hmm for some reason the char.At isnt working
    By dvsumosize in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 2nd, 2010, 04:27 AM