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 4 of 4

Thread: Problems with focussing JFrame

  1. #1
    Junior Member
    Join Date
    Jun 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problems with focussing JFrame

    Hello fellow Java programmers,

    I have a problem with focusing a JFrame on top. I'll be really gald if anyone can help me out.

    I created a JButton on a JPanel(which inturn is a part of another JPanel). I would like to have a window pop up when this button is clicked. Unfortunately the window I created(JFrame) pops, but stays behind this JPanel and I can only see it after I close this JPanel. I used the setAlwaysOnTop(true), but to no use. Infact, doing so is causing the JPanel to stay always on top. Here is the code for action performed event of the button
    		mButton.addActionListener(new ActionListener()
    		{
    			public void actionPerformed(ActionEvent e)
    			{	
    				startMetadataEdit();
    		            }
    		        });
     
    	}
    	private void startMetadataEdit() {
    					MarkerMetadata mmd = getMetadata();
    					MetadataEditPanel mMep = new MetadataEditPanel(mmd);
    					mMep.setVisible(true);
     
    	}

    The constructor of MetadataEditPanel contains a function initComponents(), which declares and defines the components of the pop-up window. I tried putting all sorts of function calls in initCompnents(), like setAlwaysonTop(true), setFocusable(true), but nothing worked out. I created this UI on netbeans and i'm using this code in Eclipse(Yes, I'm a bit lazy to write GUI code).

    So, does anyone have any suggestions/solutions? Thanks in advance


  2. #2
    Member Faz's Avatar
    Join Date
    Mar 2010
    Posts
    97
    Thanks
    5
    Thanked 14 Times in 14 Posts

    Default Re: Problems with focussing JFrame

    You wouldn't have the other JFrame to always be on top too would you?

    EDIT:
    Also what version of Java are you using?
    Last edited by Faz; June 29th, 2010 at 07:51 AM.

  3. #3
    Junior Member
    Join Date
    Jun 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Problems with focussing JFrame

    No, I need to JFrame to stay behind while the poped up window stays. Infact, I want that users can't use JFrame until they finish using the poped up window.

    I'm using java 6. Are there any known problems with Java 6 Swing?

    Thanks,

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Problems with focussing JFrame

    Quote Originally Posted by ozymann View Post
    No, I need to JFrame to stay behind while the poped up window stays. Infact, I want that users can't use JFrame until they finish using the poped up window.

    I'm using java 6. Are there any known problems with Java 6 Swing?

    Thanks,
    If this is the behavior you would like, then you may want to create a JDialog, calling setModal(true) to make the dialog modal. From what you posted, its hard to say why your current implementation is behaving this way. I'd suggest you create a short, runnable code which reproduces the problem so others can offer up advice.

Similar Threads

  1. Print out a JFrame
    By ellias2007 in forum AWT / Java Swing
    Replies: 8
    Last Post: June 17th, 2010, 06:15 AM
  2. JFrame Edit
    By n00b123 in forum AWT / Java Swing
    Replies: 1
    Last Post: May 19th, 2010, 08:23 PM
  3. JPanel in JFrame
    By maele in forum AWT / Java Swing
    Replies: 2
    Last Post: March 8th, 2010, 04:12 AM
  4. JFrame help
    By Uden in forum AWT / Java Swing
    Replies: 0
    Last Post: August 14th, 2009, 01:37 PM
  5. Replies: 3
    Last Post: February 26th, 2009, 05:21 PM