Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
- public class Pr2 extends JFrame
- {
- public JFrame f=new JFrame();
- public JPanel p=new JPanel();
- public JMenuBar mb = new JMenuBar();
- public JMenu m1 = new JMenu("File");
- public JMenuItem mi1=new JMenuItem("New");
- public JMenuItem mi2=new JMenuItem("Exit");
- public JMenu m2=new JMenu("Edit");
- public JTextArea ta=new JTextArea(10,30);
- public Pr2() {}
- public Pr2(String titlu) {
- super(titlu);
- setJMenuBar(mb);
- mb.add(m1);
- m1.add(mi1);
- m1.add(mi2);
- mb.add(m2);
- f.add(p, BorderLayout.CENTER);
- p.add(ta );
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- mi2.addActionListener( new ActionListener(){
- public void actionPerformed(ActionEvent ev){
- System.exit(0);
- }
- }
- );
- mi1.addActionListener( new ActionListener(){
- public void actionPerformed(ActionEvent ev){
- String s=JOptionPane.showInputDialog("introduceti text");
- ta.append(s+"\n");
- }
- }
- );
- }
- }
Add Comment
Please, Sign In to add comment