Forums Register Login

Swing Clear Fields and CheckBoxes

+Pie Number of slices to send: Send
I have an internal Frame that has several TextFields and CheckBoxes, and I would like to be able to clear all the data with the push of a button. Is there anyway to do that without removing and then adding each component?
+Pie Number of slices to send: Send
just keep references to these clearing components, and when you push your button, set the text field values to "" and set the checkboxes to false.
+Pie Number of slices to send: Send
Ok, I undertand that, but how do I get the window to refresh itsleft so that everything is cleared?
+Pie Number of slices to send: Send
Try a call to validate();
+Pie Number of slices to send: Send
I can't seem to find that method on java.sun. Can you point me to a link of the API that explains that, or explain what validate() does?
+Pie Number of slices to send: Send
Go here and look in the Container class:
http://java.sun.com/j2se/1.3/docs/api/index.html
I would recommend downloading these docs:
http://java.sun.com/j2se/1.3/docs.html
I use them all day for quick reference.
+Pie Number of slices to send: Send
So, if I understand, which I rarely do at first. If I have a checkbox called: GenderCheck, RaceCheck, etc, I can clear all those with one validate() method on the container? What if my container is a JTabbedPane? I can't seem to get it to work. I have JTabbedPane topPane = new JTabbedPane()
Then when I click a button I have topPane.validate()
Is that right or wrong?
+Pie Number of slices to send: Send
That should work, I just tried it with
a JPanel and a JFrame and both times it
repainted the screen correctly. I'll try it
with a JTabbedPane and let you know.
+Pie Number of slices to send: Send
Thanks, I would appreciate it. I have had some problems with JTabbedPanes repainting correctly on some other functions as well. And the same functions worked with a JFrame. So it must be something in the JTabbedPane. But thanks for your help and let me know.
+Pie Number of slices to send: Send
Try this:
On any Jcomponent(e.g. your JTabbedPane):
myJTabbedPane.getTopLevelAncestor().validate()
Ensure via System.out.println that the getTopMostAncestor()
returns your top level JFrame(As a sanity check).
This should redraw the entire app frame and your
TabbedPane.
Get off me! Here, read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1910 times.
Similar Threads
How to find Checkboxes?
retrieving users' bookmarks
Select All and Clear All implementation in JSF
problem with checkbox event in jsp page
How to set the background color of check box?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 14:54:03.