-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestbox.java
51 lines (44 loc) · 992 Bytes
/
Testbox.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
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Testbox extends JFrame implements ActionListener
{
String mess[] ={"m1","2","3"};
JComboBox box =new JComboBox(mess);
JLabel b1;
public static void main(String[] arg)
{
Testbox t=new Testbox();
//CenterFrame(t);
//MaximisiFrame(t);
t.setVisible(true);
}
public Testbox()
{
setLayout(new FlowLayout());
setSize(400,500);
setTitle("Testbox");
b1 =new JLabel();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
box.setSelectedIndex(1);
box.addActionListener(this);
add(box);
add(b1);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==mess){
Testbox cd =(Testbox)e.getSource();
String msg =(String)cd.getSelectedItem();
switch(msg){
case "1":b1.setText("hii babs");
break;
case "2":b1.setText("hii baby");
break;
case "3":b1.setText("hii dogy");
break;
default:b1.setText("oops error...");
}
}
}
}