-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDuplicateAnima.java
More file actions
55 lines (48 loc) · 1.59 KB
/
DuplicateAnima.java
File metadata and controls
55 lines (48 loc) · 1.59 KB
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
package q3;
//ofri rom:208891804
//avigail shekasta:209104314
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class DuplicateAnima extends JDialog implements ActionListener {
JButton ok;
JComboBox<String> cmb;
static Swimmable temp;
AddAnimalDialog dialog;
static boolean flag=false;
public DuplicateAnima(){
JPanel panel1 = new JPanel();
JLabel size1 = new JLabel("בחר חיה לשכפול:");
panel1.add(size1,BorderLayout.NORTH);
pack();
cmb = new JComboBox<String>();
for (Swimmable i: AquaPanel.set)
cmb.addItem(i.to_string());
cmb.setSize(1000,30);
panel1.add(cmb,BorderLayout.CENTER);
ok = new JButton("אישור");
ok.addActionListener(this);
panel1.add(ok, BorderLayout.SOUTH);
panel1.setSize(600, 50);
add(panel1);
setSize(550, 150);
setTitle("הוספת חיה");
}
@Override
public void actionPerformed(ActionEvent e) {
/**
* this method perform the task according to the source that comes in the signature of this method
*/
if (e.getSource().equals(ok)){
for (Swimmable i:AquaPanel.set){
if(cmb.getSelectedItem().toString().equals(i.to_string()))
temp=i.clone();
}
flag=true;
dialog = new AddAnimalDialog();
dialog.setVisible(true);
this.dispose();
}
}
}