Notepad GUI synthesis

Source: Internet
Author: User

1  PackageJFrame;2 3 Importjava.awt.*;4 Importjavax.swing.*;5  Public classJPanel8extendsjframe{6     //menu bar, not participating in layout7 jmenubar MB;8     //node-level menus9Jmenu[] Menu = {NULL,NULL,NULL,NULL,NULL};Ten JMenu mn00; One     //leaf node level menu AJmenuitem[] Mn000_1 = {NULL,NULL}; -Jmenuitem[] Mn01_7 = {NULL,NULL,NULL,NULL,NULL,NULL}; -     //Tool Bar the JToolBar TB; -Jbutton[] bt={NULL,NULL,NULL,NULL,NULL,NULL}; -     //text Field - JTextArea ta; +     //scroll bar - JScrollPane SCP; +     //Panel Ajpanel[] pn = {NULL,NULL}; at      PublicJPanel8 () { -         //Menu Bar -Menu[0] =NewJMenu ("File (F)"); -         //This method is now obsolete, use Setmnemonic (int) to set the mnemonic for the button. This method is designed to handle only the character values from ' a ' to ' Z ' or ' a ' to ' Z '. -Menu[0].setmnemonic (' F '); -MENU[1] =NewJMenu ("edit (E)"); inMenu[1].setmnemonic (' E '); -MENU[2] =NewJMenu ("Format (O)"); toMenu[2].setmnemonic (' O '); +MENU[3] =NewJMenu ("View (V)"); -Menu[3].setmnemonic (' V '); theMENU[4] =NewJMenu ("Help (H)"); *Menu[4].setmnemonic (' H '); $         Panax Notoginseng         //level Menu -Mn00 =NewJMenu ("New (N)"); theMn00.setmnemonic (' N '); +Mn01_7[0] =NewJMenuItem ("Open (O)",NewImageIcon ("Images/open01.png")); AMn01_7[0].setmnemonic (' O '); theMN01_7[1] =NewJMenuItem ("Save (s)",NewImageIcon ("Images/keep02.png")); +Mn01_7[1].setmnemonic (' S ')); -MN01_7[2] =NewJMenuItem ("Save As"); $MN01_7[3] =NewJMenuItem ("Page Setup"); $MN01_7[4] =NewJMenuItem ("Print"); -MN01_7[5] =NewJMenuItem ("Exit"); -          the         //Level Two menu -Mn000_1[0] =NewJMenuItem ("File",NewImageIcon ("Images/text.png"));WuyiMN000_1[1] =NewJMenuItem ("template"); the          -         //Add menu--start WuMn00.add (mn000_1[0]); -Mn00.add (mn000_1[1]); About          $Menu[0].add (mn00); -          for(inti=0;i<6;i++){ -Menu[0].add (Mn01_7[i]); -         } AMB =NewJMenuBar (); +          for(inti=0;i<5;i++){ the Mb.add (Menu[i]); -         } $         //end--Add Menu the          the         //Add toolbar--start theTB =NewJToolBar (); the         /* - JButton () in creates a button with no text or icon set.  the JButton (Action a) the creates a button whose properties are obtained from the provided Action.  About JButton (icon icon) the Create a button with an icon.  the JButton (String text) the creates a button with text.  + JButton (String Text, icon icon) - Create a button with the initial text and icon.  the Bayi          */ theBt[0] =NewJButton (NewImageIcon ("Images/new.png")); theBt[0].settooltiptext ("New"); -BT[1] =NewJButton (NewImageIcon ("Images/open.png")); -Bt[1].settooltiptext ("Open"); theBT[2] =NewJButton (NewImageIcon ("Images/keep.png")); theBt[2].settooltiptext ("Save"); theBT[3] =NewJButton (NewImageIcon ("Images/cut.png")); theBt[3].settooltiptext ("Cut"); -BT[4] =NewJButton (NewImageIcon ("Images/copy.png")); theBt[4].settooltiptext ("Copy"); theBT[5] =NewJButton (NewImageIcon ("Images/paste.png")); theBt[5].settooltiptext ("Paste");94         //button to add to toolbar the          for(inti=0;i<6;i++){ the Tb.add (Bt[i]); the         }98         //end--Adding toolbars About          -         //Add a text field--start101TA =NewJTextArea ();102SCP =NewJScrollPane (TA);103 //Scp.add (TA);104         //end--Adding a text field the         106         //Add component to panel--start107 //pn[0] = new JPanel ();108 //pn[1] = new JPanel ();109 //Pn[0].add (TB); the //Pn[1].add (SCP);111         //end--components to the panel the         113         //components and panels added to the container--start the          This. Setjmenubar (MB); the          This. Add (Tb,borderlayout.north); the          This. Add (SCP);117         //end--components and panels added to the container118         119         //Container Properties -          This. settitle ("Oh Da");121          This. SetSize (400,400);122 //this.setresizable (false);123          This. setlocation (200,200);124          This. Setdefaultcloseoperation (jframe.exit_on_close); the          This. setvisible (true);126     }127      Public Static voidMain (string[] args) { -         NewJPanel8 ();129     } the }131  the  

Notepad GUI synthesis

Related Article

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.