A little code for a Javanese border today.

Source: Internet
Author: User
Tags gety

First remove the Border setundecorated (true);//Add the label as the Close button JLabel Subcloselabel = new JLabel ("");//The position of the button subcloselabel.setbounds (860, 0 , 40, 30);//Click Listen Subcloselabel.addmouselistener (New Mouseadapter () {@Overridepublic void mouseclicked (MouseEvent e) { JLabel closelabel= (JLabel) E.getsource ();//Get top-Level form Subwindow mysubwindowbuider= (subwindow) Closelabel.gettoplevelancestor (); Mysubwindowbuider.dispose ();}}); Subpanel.setlayout (null);//Add label as minimized button JLabel Subminimizelabel = new JLabel (""); Subminimizelabel.setbounds (822, 0, 40, 30); Subminimizelabel.addmouselistener (New Mouseadapter () {@Overridepublic void mouseclicked (MouseEvent e) {JLabel Minimizelabel= (JLabel) E.getsource (); Subwindow mysubwindowbuider= (Subwindow) minimizelabel.gettoplevelancestor (); Mysubwindowbuider.setextendedstate (jframe.iconified);}}); /Drag the label JLabel Subdraglabel = new JLabel (""); Subdraglabel.setbounds (0, 0, 822, 30); Subdraglabel.addmousemotionlistener (New Mousemotionadapter () {@Overridepublic void mousedragged (MouseEvent e) { JLabel draglabel= (JLabel) E.getsource (); Subwindow mywindowbuider= (Subwindow) draglabel.gettoplevelancestor (); Point P = mywindowbuider.getlocation (); Mywindowbuider.setlocation (p.x+ (E.getx ()-suborigin.x), p.y+ (E.gety ()-suborigin.y)); }}); Subdraglabel.addmouselistener (New Mouseadapter () {@Overridepublic void mousepressed (MouseEvent e) {suborigin.x= E.getx (); Suborigin.y=e.gety ();});                                                                                                                            Subpanel.add (Subdraglabel);

  

A little code for a Javanese border today.

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.