Results 1 to 16 of 16

Thread: JFrame ??

  1. #1
    sweet angle is offline Member
    Join Date
    Jul 2008
    Posts
    22
    Rep Power
    0

    Question JFrame ??

    hi every one..
    i have create JFrame class called frame1.>>which include button "new"

    i've also created another class called frame2.>>which include button called "OK".

    what i need is when i click the button "new" frame2 appears on the top of frame1 and then when i click button "OK" i go back to frame1?

    i hope that i wrote my question clearly!
    can any body helpme :confused:.

  2. #2
    shwein is offline Member
    Join Date
    Sep 2008
    Posts
    38
    Rep Power
    0

    Default

    are frame1 and frame2 internal frames that you want to call in a container of some sort?
    It is quite easy to open a second Frame from a button or a menu item by adding an ActionListener to it, but I am not convinced that is what you want. Or use the 'setVisible()' method.
    ...i guess...

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by sweet angle View Post
    what i need is when i click the button "new" frame2 appears on the top of frame1 and then when i click button "OK" i go back to frame1?
    Do you want to show/open a frame on a button click, and on another click close that frame only? Can you bit clear up.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    Is he talking about changing which window is in front (z-order??). Will requestFocus() do that?

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    Don't use two frames. Make the second one a modal JDialog.

    db

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    or simply a call to JOptionPane.showMessageDialog(...).

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by Fubarable View Post
    or simply a call to JOptionPane.showMessageDialog(...).
    To show a JFrame??? :confused:

  9. #9
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    Quote Originally Posted by Eranga View Post
    To show a JFrame??? :confused:
    See #6.

    db

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  11. #11
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    The message argument to JOptionPane.showMessageDialog is of type Object. If the parameter is a Component, the JOptionPane loads and shows that component in the message area. See the description for parameter message in the API: JOptionPane (Java Platform SE 6)

    The OP's problem description would be much better approached with a modal dialog, and JOptionPane provides a convenient static method to display one.

    db

  12. #12
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  13. #13
    sweet angle is offline Member
    Join Date
    Jul 2008
    Posts
    22
    Rep Power
    0

    Default

    thanks for your help..
    i'll try to do as what darryl.broke said and i'll see if it work..

  14. #14
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    Quote Originally Posted by sweet angle View Post
    thanks for your help..
    i'll try to do as what darryl.broke said and i'll see if it work..
    :confused:

    I'm broke?:rolleyes:

  15. #15
    sweet angle is offline Member
    Join Date
    Jul 2008
    Posts
    22
    Rep Power
    0

    Default

    sorry... for that..
    darryl.Burke ;)
    my english is bad:p

  16. #16
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. how to use JFrame in JSP ??
    By priyanka sharma in forum JavaServer Pages (JSP) and JSTL
    Replies: 8
    Last Post: 04-06-2011, 04:51 AM
  2. loading a new Jframe
    By Ebylord in forum New To Java
    Replies: 0
    Last Post: 07-22-2008, 08:31 PM
  3. opening of an exe in JFrame
    By smartsubroto in forum New To Java
    Replies: 3
    Last Post: 07-16-2008, 05:01 AM
  4. jframe
    By amith in forum AWT / Swing
    Replies: 1
    Last Post: 05-15-2008, 10:03 AM
  5. Help with JFrame
    By Albert in forum AWT / Swing
    Replies: 2
    Last Post: 07-04-2007, 04:44 AM

Posting Permissions

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