-
Notifications
You must be signed in to change notification settings - Fork 0
/
InternalDemo.java
70 lines (58 loc) · 1.49 KB
/
InternalDemo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package internaldemo;
import javax.swing.*;
import java.awt.event.*;
class MyInternalFrame extends JInternalFrame
{
static int count=0;
JTextArea ta;
JScrollPane sp;
MyInternalFrame()
{
super("DOcuments"+(++count),true,true,true,true);
ta=new JTextArea();
sp=new JScrollPane(ta);
add(sp);
JMenuBar mb=new JMenuBar();
JMenu file=new JMenu("File");
JMenuItem m1=new JMenuItem("Save");
file.add(m1);
mb.add(file);
setJMenuBar(mb);
setSize(300,300);
setLocation(50,50);
setVisible(true);
}
}
class MyFrame extends JFrame implements ActionListener
{
JDesktopPane dp;
MyFrame()
{
super("Internal Frame Demo");
dp=new JDesktopPane();
setContentPane(dp);
JMenuBar mb=new JMenuBar();
JMenu d=new JMenu("Document");
JMenuItem m1=new JMenuItem("new");
d.add(m1);
mb.add(d);
setJMenuBar(mb);
m1.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
MyInternalFrame mi=new MyInternalFrame();
dp.add(mi);
}
}
public class InternalDemo {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
MyFrame f=new MyFrame();
f.setSize(500,500);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}