-
Notifications
You must be signed in to change notification settings - Fork 21
/
UserGraphic.txt
113 lines (74 loc) · 2.24 KB
/
UserGraphic.txt
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class UserGraphic {
private JFrame frame;
private JLabel lblTitleLabel;
private JTextField inputTextField;
private JButton btnGetMessage;
private JLabel lblOutputMessage;
private MyProgram mp;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UserGraphic window = new UserGraphic();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public UserGraphic() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
mp = new MyProgram();
lblTitleLabel = new JLabel("First Program");
lblTitleLabel.setHorizontalAlignment(SwingConstants.CENTER);
lblTitleLabel.setBounds(142, 26, 159, 31);
frame.getContentPane().add(lblTitleLabel);
inputTextField = new JTextField();
inputTextField.setBounds(157, 83, 130, 26);
frame.getContentPane().add(inputTextField);
inputTextField.setColumns(10);
btnGetMessage = new JButton("Click Me");
btnGetMessage.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mp.setVar(getMessage());
setMessage(mp.getVar());
}
});
btnGetMessage.setToolTipText("Something fun");
btnGetMessage.setBounds(167, 132, 117, 29);
frame.getContentPane().add(btnGetMessage);
lblOutputMessage = new JLabel("");
lblOutputMessage.setBounds(156, 212, 145, 31);
frame.getContentPane().add(lblOutputMessage);
}
public String getMessage() {
return inputTextField.getText();
}
public void setMessage(String s) {
lblOutputMessage.setText(s);
}
}