Home Discussion Discuss: Java Swing

  • notepad demoStephen May 24, 2011 at 1:11 PM

    A new window is getting opened but i'm unable to get the output. This is my code: import java.awt.BorderLayout; import java.awt.Font; import java.awt.TextArea; import java.awt.event.*; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; public class NotepadDemo implements ActionListener { JFrame f=new JFrame(); JMenuBar mb=new JMenuBar(); JMenu file=new JMenu(); JMenu edit=new JMenu(); JMenu format=new JMenu(); JMenu view=new JMenu(); JMenu help=new JMenu(); private TextArea textArea = new TextArea("", 0,0, TextArea.SCROLLBARS_VERTICAL_ONLY); public static void main(String args[]){ NotepadDemo ntpd=new NotepadDemo(); } public NotepadDemo() { f.setTitle("Untitled - Notepad"); f.setSize(500,400); f.setResizable(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); textArea.setFont(new Font("Century Gothic", Font.BOLD, 12)); f.getContentPane().setLayout(new BorderLayout()); f.getContentPane().add(textArea); JMenuItem f1=new JMenuItem("New"); file.add(f1); JMenuItem f2=new JMenuItem("Open..."); file.add(f2); JMenuItem f3=new JMenuItem("Save"); file.add(f3); JMenuItem f4=new JMenuItem("Save As..."); file.add(f4); file.addSeparator(); JMenuItem f5=new JMenuItem("Page Setup"); file.add(f5); JMenuItem f6=new JMenuItem("Print..."); file.add(f6); file.addSeparator(); JMenuItem f7=new JMenuItem("Exit"); file.add(f7); mb.add(file); JMenuItem e1=new JMenuItem("Undo"); edit.add(e1); edit.addSeparator(); JMenuItem e2=new JMenuItem("Cut"); edit.add(e2); JMenuItem e3=new JMenuItem("Copy"); edit.add(e3); JMenuItem e4=new JMenuItem("Paste"); edit.add(e4); JMenuItem e5=new JMenuItem("Delete"); edit.add(e5); edit.addSeparator(); JMenuItem e6=new JMenuItem("Find..."); edit.add(e6); JMenuItem e7=new JMenuItem("Find Next"); edit.add(e7); JMenuItem e8=new JMenuItem("Replace"); edit.add(e8); JMenuItem e9=new JMenuItem("Go To..."); edit.add(e9); edit.addSeparator(); JMenuItem e10=new JMenuItem("Select All"); edit.add(e10); JMenuItem e11=new JMenuItem("Time/Date"); edit.add(e11); mb.add(edit); JMenuItem fm1=new JMenuItem("Word Wrap"); format.add(fm1); JMenuItem fm2=new JMenuItem("Font..."); format.add(fm2); mb.add(format); JMenuItem v1=new JMenuItem("Status Bar"); view.add(v1); mb.add(view); JMenuItem h1=new JMenuItem("View Help"); help.add(h1); help.addSeparator(); JMenuItem h2=new JMenuItem("About Notepad"); help.add(h2); mb.add(help); f.getContentPane().add(mb); f.setVisible(true); } public void actionPerformed(ActionEvent e) { } }

  • ttttttM.Dineshkumar June 2, 2011 at 11:47 AM

    thank u

  • Referencerajasekar July 11, 2011 at 9:12 AM

    how use it text box and label box,check box and other useful information send

  • QuestionKamlesh Yadav August 26, 2011 at 10:01 PM

    diffrence between String class and JButton class

  • swing detailmanmath eklare November 21, 2011 at 12:32 PM

    how develop gui with swong

  • jjmanu December 21, 2011 at 3:40 PM

    i like it.bt need 2 improve

  • jjmanu December 21, 2011 at 3:42 PM

    i like it.bt need 2 improve

  • acountRoz Gerhardth V. Estrada May 12, 2012 at 5:50 AM

    for just an exampled

  • java swingrajagopal June 20, 2012 at 2:34 PM

    thank you

  • core javasaara August 28, 2012 at 3:59 PM

    need ur guidance more

  • swing and awtsandeep singh November 4, 2012 at 1:23 PM

    does the swing overlap the awt which is advanced work tool and the animation of both these field relate to each other or not?

  • swingsanthosh December 3, 2012 at 12:14 PM

    send me sample program of employeement registration form

  • javavikas pal November 7, 2011 at 4:49 PM

    tis site is very useful.

Post your Comment



Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Related Articles
DMCA.com