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

Accessing dynamic Components  RSS feed

 
M Khanna
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi...
I am new to Swing, and I am having a problem with accessing dynamically created components.
Essentially what I am trying to do is this...

I have a set of JTextFileds and JButtons which are created dynamically- i.e - the number to be created is dynamic- no problem with that - i can create them in a loop


Now what happens is that on Click of the button, a JDialogBox shows up and the user has to select from a List of values(this has already been coded). On Clicking OK, on the dialog box, the JTextField for the Button that was clicked has to be populated with the value selected in the DialogBox, and I can't seem to get access to this textField.
Any help will be appreciated.

Thanks,
Meera
 
M Khanna
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
p.s.

I am passing a reference of my panel to the JDialogBox, so i can access the public methods in the panel from the dialog box. If there is only one text box and one button, I can set the value of the text box from the dialog box, using the public setter method of the textfield.
The problem is with the dynamic addition of the textfields/buttons and how to reference/access them.

Any help/insight is appreciated.

Thanks again...
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is one of the ways (no error handling)
 
M Khanna
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks..... this was really helpful.
The only thing was that the dialog box that is shown on click of the button is a little more complicated than an optionPane. Anyways, this gave me an idea about how to start tackling the problem.

Thanks again.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!