Java Swing Learning Summary

Source: Internet
Author: User

1. Make the form in the center of the screen

Dimension Welcomescreen=toolkit.getdefaulttoolkit (). Getscreensize ();        int x= (Welcomescreen.width-this.getsize (). width)/2;        int y= (Welcomescreen.height-this.getsize (). height)/2;        This.setbounds (x, Y, 500, 400);

2. Set File filter

private void Jbutton1actionperformed (Java.awt.event.ActionEvent evt) {                                                 //TODO Add your handling code here:        Jfilechooser1.setfilefilter (New FileFilter () {            @Override public            Boolean accept (File f) {                return f.getname (). toLowerCase (). EndsWith (". txt") | | F.isdirectory (); To change body of generated methods, choose Tools | Templates.            }            @Override public            String getdescription () {                return ". txt file";//to change body of generated methods, choose Tools | Templates.            }        });        Jfilechooser1.showopendialog (this);    }                              

Java Swing Learning Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.