-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGui1.java
More file actions
38 lines (33 loc) · 973 Bytes
/
Copy pathGui1.java
File metadata and controls
38 lines (33 loc) · 973 Bytes
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
package Lab4;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Gui1 extends JFrame
{
JTextArea textArea = new JTextArea(15,10);
JScrollPane Scroll = new JScrollPane(textArea);
JButton button = new JButton("Add some Text");
public Gui1()
{ super("Example");
setSize(500,500);
setLayout(new FlowLayout());
add(textArea);
add(Scroll);
setVisible(true);
add(button);
Scroll.setViewportView(textArea);
button.addActionListener (new ActionListener()
{
public void actionPerformed(ActionEvent
ae)
{
String txt = JOptionPane.showInputDialog(null,"Insert some text");
textArea.append(txt);
}
});
}
public static void main(String[]args)
{
new Gui1().setVisible(true);
}
}