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: Problem with a JFrame method

  1. #1
    Junior Member
    Join Date
    May 2010
    Location
    Ratnapura,Sri Lanka
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Problem with a JFrame method

    This is my java program and I can't understand the difference between (JFrame.HIDE_ON_CLOSE) & (JFrame.DISPOSE_ON_CLOSE ) methods.Can you please explain this?

    import javax.swing.*;
    class DemoJLabel extends JFrame{
    JLabel lbl1;
    DemoJLabel(){
    lbl1=new JLabel("My Label");
    add(lbl1);
    setTitle("JLabelDemo");
    // setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    pack();
    setVisible(true);
    }
    }
    class MyDemoLabel{
    public static void main(String []args){
    DemoJLabel jlabel=new DemoJLabel();
    }
    }


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

    Default Re: Problem with a JFrame method

    Dispose actually disposes the window and all its associated components. Hide just hides the JFrame, in case you wish to make the window visible again with the same state(s) it had when it was closed.

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. dynamic method problem...
    By Ranger-Man in forum Object Oriented Programming
    Replies: 8
    Last Post: September 7th, 2009, 04:22 PM
  3. JFrame help
    By Uden in forum AWT / Java Swing
    Replies: 0
    Last Post: August 14th, 2009, 01:37 PM
  4. Change JFrame components problem
    By bruno88 in forum AWT / Java Swing
    Replies: 0
    Last Post: June 30th, 2009, 01:25 PM
  5. problem with Scanner nextLine() method
    By mia_tech in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: March 10th, 2009, 04:14 AM