Guest User

Untitled

a guest
Jul 15th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.awt.*;
  3. import java.awt.event.*;
  4.  
  5. public class Pr2 extends JFrame
  6. {
  7. public JFrame f=new JFrame();
  8. public JPanel p=new JPanel();
  9. public JMenuBar mb = new JMenuBar();
  10.  
  11. public JMenu m1 = new JMenu("File");
  12. public JMenuItem mi1=new JMenuItem("New");
  13. public JMenuItem mi2=new JMenuItem("Exit");
  14. public JMenu m2=new JMenu("Edit");
  15.  
  16. public JTextArea ta=new JTextArea(10,30);
  17.  
  18. public Pr2() {}
  19.  
  20. public Pr2(String titlu) {
  21. super(titlu);
  22.  
  23. setJMenuBar(mb);
  24.  
  25. mb.add(m1);
  26. m1.add(mi1);
  27. m1.add(mi2);
  28. mb.add(m2);
  29.  
  30. f.add(p, BorderLayout.CENTER);
  31. p.add(ta );
  32.  
  33. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  34.  
  35. mi2.addActionListener( new ActionListener(){
  36. public void actionPerformed(ActionEvent ev){
  37. System.exit(0);
  38. }
  39. }
  40. );
  41.  
  42.  
  43. mi1.addActionListener( new ActionListener(){
  44. public void actionPerformed(ActionEvent ev){
  45. String s=JOptionPane.showInputDialog("introduceti text");
  46. ta.append(s+"\n");
  47. }
  48. }
  49. );
  50. }
  51.  
  52.  
  53. }
Add Comment
Please, Sign In to add comment