-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasics17.java
More file actions
54 lines (43 loc) · 1.52 KB
/
Basics17.java
File metadata and controls
54 lines (43 loc) · 1.52 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
package irene;
import javax.swing.*;
import java.awt.*;
public class Basics17 {
public static void main(String[] args) {
JFrame mainFrame= new JFrame();
mainFrame.setTitle("Sign up form");
mainFrame.setSize(300,300);
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new GridLayout(6,2,10,10));
JLabel nameLabel = new JLabel("Name");
JTextField nameField = new JTextField();
JLabel emailLabel = new JLabel("Email");
JTextField emailField = new JTextField();
JLabel genderLabel = new JLabel("Gender");
JRadioButton male = new JRadioButton("Male");
JRadioButton female = new JRadioButton("Female");
ButtonGroup buttonGroup = new ButtonGroup();
buttonGroup.add(male);
buttonGroup.add(female);
JPanel genderPanel = new JPanel();
genderPanel.setLayout(new FlowLayout());
genderPanel.add(male);
genderPanel.add(female);
JLabel countryLabel = new JLabel("Country");
String [] countries = {"India","China","USA"};
JComboBox<String> countryBox = new JComboBox<>(countries);
JLabel addressJLabel = new JLabel("Address");
JTextArea addressArea = new JTextArea(3,4);
JButton submitbtn = new JButton("Submit");
mainPanel.add(nameLabel);mainPanel.add(nameField);
mainPanel.add(emailLabel);mainPanel.add(emailField);
mainPanel.add(genderLabel);
mainPanel.add(genderPanel);
mainPanel.add(countryLabel);mainPanel.add(countryBox);
mainPanel.add(addressJLabel);
mainPanel.add(addressArea);
mainPanel.add(submitbtn);
mainFrame.add(mainPanel);
mainFrame.setLocationRelativeTo(null);
mainFrame.setVisible(true);
}
}