I was trying to reduce my jtextfield height, since it is for user to enter first name.
somehow when i run the code, the box is just too big, is there anyway to change the textfield height? i tried with setPrefferedSize but somehow it showing error, mayb i put it wrongly in a wrong place
Totally a beginner here....
here is my code
import java.util.*;
import javax.swing.*;
import javax.swing.JList;
import javax.swing.ButtonGroup;
import java.awt.*;
import java.awt.BorderLayout;
public class RegistrationSystem extends JPanel{
JLabel lblfirstname = new JLabel("First Name:");
JLabel lbllastname = new JLabel("Last Name:");
JLabel lblage = new JLabel("Age:");
JLabel lblgender = new JLabel("gender:");
JLabel lblworkshop = new JLabel("Workshop:");
JLabel lblhotelroom = new JLabel("Hotel:");
JLabel lblmobphone = new JLabel("Phone(mob):");
JLabel lblphone = new JLabel("Phone:");
JLabel lblstudent = new JLabel("Student:");
JTextField jtffirstname = new JTextField();
JTextField jtflastname = new JTextField();
JTextField jtfage = new JTextField();
JTextField jtfmobphone = new JTextField();
JTextField jtfphone = new JTextField();
JPanel jpradiogender = new JPanel(new BorderLayout());
JRadioButton jrbmale = new JRadioButton("Male");
JRadioButton jrbfemale = new JRadioButton("Female");
JPanel jpradiochoice = new JPanel(new BorderLayout());
JRadioButton jrbyes = new JRadioButton("Yes");
JRadioButton jrbno = new JRadioButton("No");
JPanel jpcheckboxworkshop = new JPanel(new BorderLayout());
JCheckBox jcbworkshop1 = new JCheckBox("The Future is Called the Sensor Web");
JCheckBox jcbworkshop2 = new JCheckBox("Distributed Information Retrieved");
JCheckBox jcbworkshop3 = new JCheckBox("Advanced Medical Technology");
JCheckBox jcbdinner = new JCheckBox("Registering for openning night dinner with keynote speech");
String hotel[] = {"None","Deluxe","Premier","Suite"};
JList jlhotel = new JList(hotel);
JButton jbtregister = new JButton("Register");
public RegistrationSystem() {
ButtonGroup genderGroup = new ButtonGroup();
genderGroup.add(jrbmale);
genderGroup.add(jrbfemale);
jpradiogender.add(jrbmale,BorderLayout.WEST);
jpradiogender.add(jrbfemale,BorderLayout.EAST);
ButtonGroup studentGroup = new ButtonGroup();
studentGroup.add(jrbyes);
studentGroup.add(jrbno);
jpradiochoice.add(jrbyes,BorderLayout.WEST);
jpradiochoice.add(jrbno,BorderLayout.EAST);
jpcheckboxworkshop.add(jcbworkshop1,BorderLayout.NORTH);
jpcheckboxworkshop.add(jcbworkshop2,BorderLayout.CENTER);
jpcheckboxworkshop.add(jcbworkshop3,BorderLayout.SOUTH);
JScrollPane listScrollPane = new JScrollPane(jlhotel);
jtffirstname.setBounds(200,50,20,20);
JPanel jpmain = new JPanel(new GridLayout(10,2));
jpmain.add(lblfirstname);
jpmain.add(jtffirstname);
jpmain.add(lbllastname);
jpmain.add(jtflastname);
jpmain.add(lblage);
jpmain.add(jtfage);
jpmain.add(lblgender);
jpmain.add(jpradiogender);
jpmain.add(lblmobphone);
jpmain.add(jtfmobphone);
jpmain.add(lblphone);
jpmain.add(jtfphone);
jpmain.add(lblstudent);
jpmain.add(jpradiochoice);
jpmain.add(lblworkshop);
jpmain.add(jpcheckboxworkshop);
jpmain.add(lblhotelroom);
jpmain.add(listScrollPane);
jpmain.add(jcbdinner);
jpmain.add(jbtregister);
JFrame frame = new JFrame("Conference Registration");
frame.add(jpmain);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400,700);
frame.setVisible(true);
frame.setLocationRelativeTo(null);
}
public static void main(String[] args) {
RegistrationSystem a = new RegistrationSystem();
}
}