-
Notifications
You must be signed in to change notification settings - Fork 0
/
PointDialog.java
49 lines (43 loc) · 1.18 KB
/
PointDialog.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
class PointDialog extends JDialog implements ActionListener{
private JTextField textfield;
private JButton ok, cut;
private String suchstring;
PointDialog(JFrame f, String titel){
super(f, titel,true);
setResizable(false);
setLayout(new BorderLayout());
JPanel panel1 = new JPanel();
JLabel label = new JLabel("Введите строку для поиска");
panel1.add(label);
textfield = new JTextField(40);
panel1.add(textfield);
add("Center", panel1);
JPanel panel2 = new JPanel();
ok = new JButton("ok");
cut = new JButton("Отмена");
panel2.add(ok);
panel2.add(cut);
add("South", panel2);
pack();
ok.addActionListener(this);
cut.addActionListener(this);
setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
}
public void actionPerformed(ActionEvent e) {
String Label;
Label = e.getActionCommand();
if(Label.equals("Отмена")){
suchstring =null;
setVisible(false);
return;
}
if(Label.equals("ok")){
suchstring =textfield.getText();
setVisible(false);
return;
}
}
public String getString(){
return suchstring;
}
}