Window effect, with border, without border, set the window border color

Source: Internet
Author: User
Import Java. AWT. borderlayout; import Java. AWT. color; import Java. AWT. dimension; import Java. AWT. toolkit; import javax. swing. borderfactory; import javax. swing. jframe; import javax. swing. jpanel; import javax. swing. border. border; import javax. swing. border. etchedborder; import javax. swing. border. titledborder; // test class public class exec {public static void main (string [] ARGs) {// create the form variable demowindow DW = new demowindow ("form with title border"); // set the width and height of the form to 1/3 of the screen width and screen height, respectively, in the upper left corner, set toolkit thekit = DW at 1/3 of the screen width and height. gettoolkit (); dimension wndsize = thekit. getscreensize (); DW. setbounds (wndsize. width/3, wndsize. height/3, wndsize. width/3, wndsize. height/3); // click the close button to exit the DW program. setdefaclocloseoperation (jframe. exit_on_close); // set the form to visible DW. setvisible (true) ;}}// interface form class demowindow extends jframe {// Title border panel jpanel JP = new jpanel (); // constructor public demowindow (String title) {super (title); // create a title border titledborder TB = borderfactory. createtitledborder (borderfactory. createlineborder (color. white), "display area"); // sets the title alignment and color TB for the title border. settitlejustification (titledborder. center); TB. settitlecolor (color. yellow); // create a raised border border2 = borderfactory. createetchedborder (etchedborder. raised); // create a composite border. Combine the title border and raised border to border newborder = borderfactory. createcompoundborder (TB, border2); // set the border JP of the Panel. setborder (newborder); // set the background color of the Panel JP. setbackground (color. gray); // display a gray normal panel JP. setlayout (New borderlayout (); JP. add (New jpanel (); // Add border panel add (JP );}}

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.