Can you group textboxes?
Thanks
In what way? Ina display, of course, simply place them next to each other. In a "query" aspect? No. Give them all "names" that start the same, maybe?
Edit: Or just simply to have a handy "list" that contains them all? Yes, just use a List or array.
In what way? Ina display, of course, simply place them next to each other. In a "query" aspect? No. Give them all "names" that start the same, maybe?
Edit: Or just simply to have a handy "list" that contains them all? Yes, just use a List or array.
I'm not sure what you mean. What I'm trying to do is this:
When an item is selected from a listbox a certain amount of textboxes appear depending on what item is selected.
I don't know how to display the textboxes.
Thank you.
Well see, how does "how do I display x num components after an event" relate to "Can you group textboxes?" ?
Create a JPanel that is to hold these "textboxes" and place it on the GUI at the beginning.
Write a selection listener, and add it to the listbox, that then removes all components from that Panel and adds the "proper number" of text boxes to it, then calls validate() and/or repaint() on that panel.
@ masijade
no FW, sure by using validate() for addOns/removes JComponents on most cases works, but correct way is revalidate()...(revalidate covered validate too), in proofApp's you have to be care and hold this rule, hmmm for example some JComponents doesn't works correctly and as you expected (JComboBox missing data from custom JList ....) and other nice stars on this heavens
if you remove or add new JComponents to the Container
revalidate();
repaint();
if you want to modified Container or its Components, and if Container and its JComponents are placed by using some LayoutManager, and this Container was once time visible then
validate();// in this case revalidate() too
repaint(); // maybe doesn't need in all cases, but just in case
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.