Package Gui1;import Java.awt.borderlayout;import javax.swing.imageicon;import javax.swing.jbutton;import Javax.swing.jframe;import Javax.swing.jmenu;import Javax.swing.jmenubar;import Javax.swing.JMenuItem;import Javax.swing.jscrollpane;import Javax.swing.jtextarea;import Javax.swing.JToolBar; Public classJishiben extends jframe{jmenubar cd;//Menu PanelJMenu CD1,CD2,CD3,CD4,CD5;//MenuJMenuItem cdx2,cdx3,cdx4,cdx5,cdx6,cdx7; JMenu EJ; JMenuItem ej1,ej2; //JMenuItem is final and cannot have the next level menu. Direct Response Application//JMenu not the most final, after clicking on the next level appearsJToolBar JTB;//Tool BarJButton Jb1,jb2,jb3,jb4,jb5,jb6; JTextArea JTA; JScrollPane JSP; Public Static voidMain (string[] args) {//TODO auto-generated Method StubJishiben js1=NewJishiben (); } PublicJishiben () {//Tool Barjtb=NewJToolBar (); JB1=NewJButton (NewImageIcon ("image/264.jpg")); Jb1.settooltiptext ("New"); JB2=NewJButton (NewImageIcon ("image/264.jpg")); Jb2.settooltiptext ("Open"); JB3=NewJButton (NewImageIcon ("image/264.jpg")); Jb3.settooltiptext ("Save"); JB4=NewJButton (NewImageIcon ("image/264.jpg")); Jb4.settooltiptext ("Cut"); JB5=NewJButton (NewImageIcon ("image/264.jpg")); Jb5.settooltiptext ("Copy"); Jb6=NewJButton (NewImageIcon ("image/264.jpg")); Jb6.settooltiptext ("Paste"); //MenuCd=NewJMenuBar (); CD1=NewJMenu ("document (F)"); Cd1.setmnemonic ('F'); CD2=NewJMenu ("edit (E)"); Cd2.setmnemonic ('E'); CD3=NewJMenu ("format (O)"); Cd3.setmnemonic ('O'); CD4=NewJMenu ("view (V)"); Cd4.setmnemonic ('V'); CD5=NewJMenu ("Help (H)"); Cd5.setmnemonic ('H'); //menu itemej=NewJMenu ("New"); Ej1=NewJMenuItem ("file",NewImageIcon ("image/263.jpg")); Ej2=NewJMenuItem ("Templates"); CDX2=NewJMenuItem ("Open",NewImageIcon ("image/263.jpg")); Cdx3=NewJMenuItem ("Save",NewImageIcon ("image/263.jpg")); CDX4=NewJMenuItem ("Save As",NewImageIcon ("image/263.jpg")); CDX5=NewJMenuItem ("Page Setup",NewImageIcon ("image/263.jpg")); cdx6=NewJMenuItem ("Print",NewImageIcon ("image/263.jpg")); CDX7=NewJMenuItem ("Exit",NewImageIcon ("image/263.jpg")); JTA=NewJTextArea (); JSP=NewJScrollPane (JTA); Ej.add (EJ1); Ej.add (EJ2); Cd1.add (EJ); Cd1.add (CDX2); Cd1.add (cdx3); Cd1.add (CDX4); Cd1.addseparator (); Cd1.add (CDX5); Cd1.add (cdx6); Cd1.addseparator ();//Add split LineCd1.add (CDX7); Jtb.add (JB1); Jtb.add (JB2); Jtb.add (JB3); Jtb.add (JB4); Jtb.add (JB5); Jtb.add (JB6); Cd.add (CD1); Cd.add (CD2); Cd.add (CD3); Cd.add (CD4); Cd.add (CD5); This. Setjmenubar (CD);//menu bar does not count toward layout This. Add (Jtb,borderlayout.north); This. Add (JSP);//add to Middle by default This. Settitle ("Notepad"); This. SetSize ( -, the); This. setlocation ( -, the); This. Seticonimage (NewImageIcon ("image/23.jpg"). GetImage ());//(New ImageIcon ("")). GetImage () This. setresizable (true); This. Setdefaultcloseoperation (Jframe.exit_on_close); This. setvisible (true); }}
A simple implementation of Swing's Notepad