JFrame.DISPOSE_ON_CLOSE

JFrame.DISPOSE_ON_CLOSE

JFrame.DISPOSE_ON_CLOSE
JFrame setDefaultCloseOperation method  can take various variables.These are

Apart from setDefaultCloseOperation,JFrame swing window has various methods.I have previously looked at some of them.Make sure you check out.

JFrame methods.


JFrame.DISPOSE_ON_CLOSE  Example

[
import javax.swing.JFrame;
import javax.swing.JPanel;

import javax.swing.JTextField;
import javax.swing.JButton;

public class JFrameMethods extends JPanel{

    JFrameMethods()
    {
        JTextField username=new JTextField("Enter Username");
        JTextField password=new JTextField("Enter Password");
        JButton login=new JButton("Login");
        JButton cancel=new JButton("Cancel");
        username.setBounds(10, 10, 100, 20);
        password.setBounds(10, 20, 100, 20);

        add(username);
        add(password);
        add(login);
        add(cancel);


    }

    public static void main(String args[])
    {
        JFrame window=new JFrame("JFrame methods");
        window.getContentPane().add(new JFrameMethods());
        window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        window.setLocationRelativeTo(null);
        window.setSize(400,400);
        window.setVisible(true);

    }

}
]

Code Explanation:

Above class extends JPanel class.Other swing components you should check out are JTextField and JButton.See also how to implement ActionListener to a JButton 

Code[window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);]-sets JFrame defaultcloseoperation method to exit the application once its clicked.



COMMENTS

Name

android arrays cnna1 graphics java java control statements java.swing JButton JFrame JLabel JTextField laravel node.js OPP questions swing technology
false
ltr
item
Code WHIZZ: JFrame.DISPOSE_ON_CLOSE
JFrame.DISPOSE_ON_CLOSE
JFrame.DISPOSE_ON_CLOSE
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRW7keK6I5ae3BN7VVtKtVIPX9DT-Se1BkQa83mg18aK-ffoBOqGssNOwKQaNsGKL45nlWk0cSutDGQxzxy-dPS1sATxJvSpEMe8zSxIs81TvDBWbt6Bt_x4bQWZRfeVE_yiB5Pq6H7ndi/s200/jframe-setdefaultcloseoperation-exit-on-close-min.PNG
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRW7keK6I5ae3BN7VVtKtVIPX9DT-Se1BkQa83mg18aK-ffoBOqGssNOwKQaNsGKL45nlWk0cSutDGQxzxy-dPS1sATxJvSpEMe8zSxIs81TvDBWbt6Bt_x4bQWZRfeVE_yiB5Pq6H7ndi/s72-c/jframe-setdefaultcloseoperation-exit-on-close-min.PNG
Code WHIZZ
https://code-whizz.blogspot.com/2017/03/jframedisposeonclose.html
https://code-whizz.blogspot.com/
http://code-whizz.blogspot.com/
http://code-whizz.blogspot.com/2017/03/jframedisposeonclose.html
true
5534598864497432585
UTF-8
Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy