こんにちは、文字列から取得した JComboBox の日付を取得しようとしています...しかし、必要に応じて GUI で変更することもできます...方法がわからないので、これに夢中になっています...乾杯 = )
public class StudentInfoGUI extends JPanel{
private JTextField stFirstName;
private JTextField stLastName;
private JComboBox birthDate,birthMonth,birthYear;
private JRadioButton genderMale,genderFemale;
private JLabel l1,l2,l3,l4,l5;
public StudentInfoGUI(){
super();
StudentInfo st = new StudentInfo("123456","Homer","Simpsons","01011970",'m');
l1 = new JLabel("First name:");
stFirstName = new JTextField(st.getFirstName());
l2 = new JLabel("Last name:");
stLastName = new JTextField(st.getLastName());
Calendar cal = new GregorianCalendar();
// int date = cal.get(Calendar.DAY_OF_MONTH);
//int month = cal.
int year = cal.get(Calendar.YEAR);
l3 = new JLabel("Birthday");
birthDate = new JComboBox();
birthDate.addItem(st.getBirthday());
//birthMonth.addItem(month);
birthYear = new JComboBox();
l4 = new JLabel("male");
genderMale = new JRadioButton();
l5 = new JLabel("female");
genderFemale = new JRadioButton();
if(st.getGender()== 'm'){
genderMale.setSelected(true);
}
else
genderFemale.setSelected(true);
JPanel stPanel = new JPanel();
stPanel.setLayout(new GridLayout(3,4));
stPanel.add(l1);
stPanel.add(stFirstName);
stPanel.add(l2);
stPanel.add(stLastName);
stPanel.add(l3);
stPanel.add(birthDate);
stPanel.add(birthMonth);
stPanel.add(birthYear);
stPanel.add(l4);
stPanel.add(genderMale);
stPanel.add(l5);
stPanel.add(genderFemale);
add(stPanel);
}
public static void main(String[] args) {
// TODO code application logic here
JFrame frame = new JFrame("Student info");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new StudentInfoGUI());
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}