Results 1 to 4 of 4
Thread: JComboBox and JTextField
- 05-30-2010, 05:43 PM #1
Member
- Join Date
- Apr 2010
- Posts
- 2
- Rep Power
- 0
JComboBox and JTextField
Hello, I am creating a program and I'm using JComboBox and Jtextfield. what i want is when ever the user selects an item from the ComboBox its supposed to show up text for example (A) in the Jtextfield.
I'm trying to use if statement but i do know how please help
the combo box model contact :
5000
15000
20000
25000
30000
35000
40000
Java Code:private void ServiceTypeTextFieldActionPerformed(java.awt.event.ActionEvent evt) { if (KmsComboBox.equals(5000)) { ServiceTypeTextField.setText("A Service"); } else { ServiceTypeTextField.setText(" "); } }
- 05-30-2010, 05:54 PM #2
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
First of all use proper Java Naming conventions which are found in any text book, tutorial or code example you might find. That is variable names start with a lower case letter, NOT an upper case latter.
You need to get the selected item from the combo box, so the code might be something like:
Java Code:String value = comboBox.getSelectedItem().toString(); if (value.equals("5000") // do something else // do something else
- 05-30-2010, 10:13 PM #3
Member
- Join Date
- Apr 2010
- Posts
- 2
- Rep Power
- 0
Thank you for helping :)
its work
- 05-31-2010, 03:20 AM #4
Cross posted
ComboBox and TextField - Java Programming Forums
fahad didn't bother to inform the other forum that the question has alreday been answered.
db
Similar Threads
-
Activate JComboBox 1 when object is selected in JComboBox 2...
By bahumbaba in forum AWT / SwingReplies: 2Last Post: 12-10-2009, 01:58 PM -
JComboBox
By pinks_70986 in forum New To JavaReplies: 2Last Post: 02-19-2009, 05:26 PM -
how to access jTextField of one JFrame1 from JFrame2 & Modify JTextField contents
By sumit1mca in forum AWT / SwingReplies: 1Last Post: 01-30-2009, 06:44 PM -
JCombobox
By daniel50096230 in forum NetBeansReplies: 1Last Post: 09-21-2008, 12:23 PM -
Making a Table Row with JPanel Composed of JTextField and JComboBox Selectable
By datechie in forum AWT / SwingReplies: 2Last Post: 07-30-2008, 12:33 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks