-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMouseClass.java
85 lines (74 loc) · 2.21 KB
/
MouseClass.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class MouseClass {
private JFrame frame;
private JTextField textField;
private JTextField textField_1;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
MouseClass window = new MouseClass();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public MouseClass() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(500, 200, 300, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JLabel lblRow = new JLabel("row");
lblRow.setFont(new Font("Tahoma", Font.BOLD, 18));
lblRow.setBounds(26, 39, 73, 35);
frame.getContentPane().add(lblRow);
JLabel lblColumn = new JLabel("column");
lblColumn.setFont(new Font("Tahoma", Font.BOLD, 18));
lblColumn.setBounds(26, 100, 91, 19);
frame.getContentPane().add(lblColumn);
textField = new JTextField();
textField.setBounds(129, 36, 116, 22);
frame.getContentPane().add(textField);
textField.setColumns(10);
textField_1 = new JTextField();
textField_1.setBounds(129, 97, 116, 22);
frame.getContentPane().add(textField_1);
textField_1.setColumns(10);
JButton btnClickMe = new JButton("GO");
btnClickMe.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try{
int a=Integer.parseInt(textField.getText());
int b=Integer.parseInt(textField_1.getText());
Grid.main(a,b);
}catch(Exception e){
JOptionPane.showMessageDialog(null, "Enter valid rows and columns");
}
}
});
btnClickMe.setBounds(73, 156, 97, 25);
frame.getContentPane().add(btnClickMe);
}
}