Results 1 to 9 of 9
  1. #1
    Tamu is offline Member
    Join Date
    Nov 2008
    Posts
    19
    Rep Power
    0

    Default pause until JFrame is closed.

    Hi,

    I am not very good with JFrame yet. Somebody know how to pause a console until JFrame is closed by clicking the cross (right-up corner)?
    Last edited by Tamu; 11-30-2008 at 06:01 PM.

  2. #2
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    10

    Default

    It will do this by it's own work. To get a window without a console, we can use javaw
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  3. #3
    Tamu is offline Member
    Join Date
    Nov 2008
    Posts
    19
    Rep Power
    0

    Default

    But I have a class to communicate with a user (with BufferedReader) in console.

    That class just open picture of JFrame corresponding to user's command until "stop"-command is given.

    I can open as many pictures I want, but if close one with a mouse, then my program will stop (console and JFrame(s)), although "stop"-command haven't given yet.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    28

    Default

    why are you mixing Swing and console apps here? It seems a poor program design. Also, are you setting the JFrame's setDefaultCloseOperation to JFrame.EXIT_ON_CLOSE? If so, don't. Or perhaps what you really want to do is show your pictures in a JOptionPane or a JDialog.

  5. #5
    Tamu is offline Member
    Join Date
    Nov 2008
    Posts
    19
    Rep Power
    0

    Default

    why are you mixing Swing and console apps here?
    I am sorry, I am new to swing. I don't know all of it's property yet. So currently I am poor in taking advance of swing properties.


    Also, are you setting the JFrame's setDefaultCloseOperation to JFrame.EXIT_ON_CLOSE?
    I have this code line in JFrame, so I think yes:

    Java Code:
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    Just in case. My JFrame have a subclass that extends JPanel to draw simple picture then add that component to JFrame.

    Close JFrame will close my console, that is bad thing i don't want to happen :(

  6. #6
    Tamu is offline Member
    Join Date
    Nov 2008
    Posts
    19
    Rep Power
    0

    Default

    I don't think JOptionPane and JDialog are things I need, because I just want to show a picture that's all.

  7. #7
    Tamu is offline Member
    Join Date
    Nov 2008
    Posts
    19
    Rep Power
    0

    Default

    I found a dirty trick. It won't solve my problem but it make feel right =)
    Dirty-trick : use "HIDE_ON_CLOSE" instead "EXIT_ON_CLOSE"

  8. #8
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    10

    Default

    I don't thinik it sounds all that bad for get-going, all a gui is is what you are doing here without the cli ( command line interface - a "dos box" )

    hide() and show() are fully legitimate, you may need to call paint or repaint or paintLater or whatever they call it today,....

    Wait tilll you get to implementing
    Java Code:
    DocFlavor flavor = new DocFlavor(new String("application/vnd.hp-PCL",new String("String"));
    You are in shallow waters brother, holler while you can.....
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    28

    Default

    Quote Originally Posted by Tamu View Post
    I don't think JOptionPane and JDialog are things I need, because I just want to show a picture that's all.
    JOptionPane can show a picture more easily than a JFrame can with less overhead on your part. A JDialog can do most of what a JFrame can and is built to not close the app when it closes.

Similar Threads

  1. Exception : ResultSet is closed
    By nanimtech in forum JDBC
    Replies: 5
    Last Post: 08-06-2009, 03:11 PM
  2. Replies: 3
    Last Post: 06-05-2008, 11:10 PM
  3. Socket Closed!
    By rameshraj in forum Networking
    Replies: 0
    Last Post: 05-06-2008, 11:48 AM
  4. Socket Closed!
    By rameshraj in forum Networking
    Replies: 0
    Last Post: 05-06-2008, 10:11 AM
  5. Help with Pause
    By trill in forum Java Applets
    Replies: 2
    Last Post: 09-28-2007, 08:50 PM

Posting Permissions

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