Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

validation for setting the text value in next text box based on selection of choices in current cho  RSS feed

 
Gopi Nash
Greenhorn
Posts: 14
Redhat Scala Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In my screen i had one button while clicking te button , it add textbox,combobox,label dynamically
I need a validation for setting the text value in next text box based on selection of choices in current choosen combobox.


I had written the code as below for

if (e.getSource().equals((JComboBox)e.getSource())) {

Object source = e.getSource();
JComboBox FieldTypePicks =(JComboBox)source;
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
//Sizevalue=e.getSource();
KeyNamePair pp = (KeyNamePair) FieldTypePicks.getSelectedItem();
int choice = 0;
if (pp != null)
choice = pp.getKey();
if (choice == 1){
JTextField Sizevalue = new JTextField();
this.requestFocus();
manager.focusNextComponent(Sizevalue);
//Sizevalue.setText()=
if (Sizevalue instanceof JTextField)
{
//Help here to set the text value in textbox near to Combobox
System.out.println("Choice1"+Sizevalue.getText());
Sizevalue.setText("GG");
}
//SizeLabelText1.setText("10");

}

please help me to set the value in Textbox
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to be honest, your description is vague (probably an english conversion problem), so you are far better off posting
a complete/compilable/runnable example so we can see on the screen what you're trying to achieve.

do not post a huge program - strip it down to dynamically adding 1 (or 2 at the most) JComboBoxes and the JTextField.
1 or 2 options only in the comboBox/s
if KeyNamePair gets values from a database, hard-code some data
run the program yourself, then write down the steps for us to take
e.g. click OK button/comboBox and textfield will appear/select item in comboBox/selected item product name is to appear in textfield

make sure we can run the cade you post i.e. no other classes required.

[edit]
and please use the code tags when posting code.
there is a code button above the text area you write into, place the cursor where you want your code to start, click the code button
and you'll see this
'['code=java][/code]
place the cursor between the ][ and paste your code there.
THEN, press the preview button to see that you've done it correctly
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!