-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUIComponents.java
More file actions
34 lines (31 loc) · 1.05 KB
/
Copy pathGUIComponents.java
File metadata and controls
34 lines (31 loc) · 1.05 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
import javax.swing.*;
public class GUIComponents {
public static void main(String[] args) {
JButton jbtOK=new JButton("OK");
JButton jbtCancel=new JButton("Cancel");
JLabel jlblName=new JLabel("Enter your name: ");
JTextField jtfName=new JTextField("Type Name Here");
JCheckBox jchkBold=new JCheckBox("Bold");
JCheckBox jchkItalic=new JCheckBox("Italic");
JRadioButton jrbRed=new JRadioButton("Red");
JRadioButton jrbYellow=new JRadioButton("Yellow");
JComboBox jcboColor=new JComboBox(new String[] {"Freshman","Sophomore","Junior","Senior"});
JPanel panel=new JPanel();
panel.add(jbtOK);
panel.add(jbtCancel);
panel.add(jlblName);
panel.add(jtfName);
panel.add(jchkBold);
panel.add(jchkItalic);
panel.add(jrbRed);
panel.add(jrbYellow);
panel.add(jcboColor);
JFrame frame=new JFrame();
frame.add(panel);
frame.setTitle("Show GUI Components");
frame.setSize(450,100);
frame.setLocation(200,100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}