• Post Reply Bookmark Topic Watch Topic
  • New Topic

JComboBox  RSS feed

 
Erwin Rommel
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i have some problems trying to display the string text to be the selected item in the JComboBox.
The JComboBox i have is in a method that is instantiated and that the JComboBox gets it's list of item from a database via SQL.
here is the code i have:
public void maintainMemberInterface() throws SQLException
{
try
{
maintainMemberWindow = new JFrame("Maintain/Update Existing Member");
maintainMemberWindow.setContentPane(new maintainMember());
maintainMemberWindow.setSize(640, 640);
maintainMemberWindow.setResizable(false);
maintainMemberWindow.setLocation(180, 50);
maintainMemberWindow.show();
maintainMemberWindow.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
maintainMemberWindow.setVisible(true);
while (memberID==null)
{
memberID = JOptionPane.showInputDialog
(null,
"Please input memberID",
"memberID please");
}
retrieveMemberFunction.retrieveMemberFunction(member, memberID);
StringTokenizer st = new StringTokenizer(member.birthdate,"/");
String arr[] = new String[st.countTokens()];
for (int i=0; st.hasMoreTokens(); i++)
{
arr[i] = st.nextToken();
}
System.out.println(arr[0]);
System.out.println(arr[1]);
System.out.println(arr[2]);
nameText.setText(member.name);
addressText.setText(member.address);
dateCombo.ssetSelectedItem(arr[0]);
monthCombo.setSelectedItem(arr[1]);
yearCombo.setSelectedItem(arr[2]);
memberTypeCombo.setSelectedItem(member.memberClass);
null1 = arr[0];
null2 = arr[1];
null3 = arr[2];
the problem is getting the JComboBox to recognise and get interface to reflect the string arr[] to be selected.
i'm not sure if i got the field correct. there is no compilation error.
thanks in advance!
 
saager mhatre
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think I quite got your problem.
You seem a little fuzzy around the edges.
Could you be a little more specific about the output you seem to be getting.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!