Results 1 to 3 of 3
  1. #1
    JavaJimme is offline Member
    Join Date
    Nov 2012
    Rep Power

    Default JFrame on top of another JFrame


    Recently I've created a chatbox. Now I've a JFrame with emoticons in it.
    I want to add it to my chat client like this : in the bottom-right corner of the chatclient.
    So the emoticon JFrame always stays in the bottom-right corner of the Chatclient when you press the emociton button even if the chatclient is on a different screen position.
    emoticonFrame.setLocationRelativeTo(null); sets it to the middel of the screen when you press the button but I need the emoticon JFrame to open at the right corner of the chatclient JFrame.
    Is there a way to do that?

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Washington, DC
    Rep Power

    Default Re: JFrame on top of another JFrame

    Why do you need it to be a JFrame instead of a JPanel? Recommended reading: How to Use Root Panes (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  3. #3
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Rep Power

    Default Re: JFrame on top of another JFrame

    Do the math yourself. If the width of the main frame is 500 and the width of the popup JDialog (don't use a JFrame) is 100, then you need to position your dialog at 400 relative to the main frame.

    You can get the location of the main frame by using the getLocationOnScreen(...) method.

    Then once you've calculated the width/height of the popup dialog you invoke the setLocation(...) method.

Similar Threads

  1. Click in JFrame Titlebar sets the JFrame Opaque
    By tim8w in forum AWT / Swing
    Replies: 1
    Last Post: 02-02-2013, 08:29 AM
  2. Transferring information from one JFrame to Another JFrame
    By cherylminor85 in forum AWT / Swing
    Replies: 4
    Last Post: 05-24-2012, 06:24 AM
  3. Replies: 3
    Last Post: 11-27-2011, 06:18 AM
  4. Replies: 5
    Last Post: 06-14-2010, 07:10 PM
  5. Replies: 4
    Last Post: 04-23-2009, 12:02 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts