Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Accessing dynamic Components

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic