Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

Adding a JButton to a panel at runtime

Thread view: 
Richard - 17 Nov 2005 20:04 GMT
Hello all

I am having a problem adding a component to a JPanel at runtime. My
code adds a new JTextField. However it does not appear when I click the
add button. The component count of the JPanel does rise by one however
everytime I click the add button so the new JTextfield is being added.
I have noticed that when I click the border of the JFrame the new
JTextfield appears then. I have tried to 'repaint' the frame and the
JPanel but I still cannot see the new added JTextField. I can only see
it when I click on the edge of the frame. It seems to force a refresh.
Can anyone help?

Thanks in advance

Richard
mrandywarner@gmail.com - 17 Nov 2005 20:55 GMT
Try calling :

panel.revalidate();
panel.repaint();

The panel needs to be revalidated to relayout the child components.
Richard - 20 Nov 2005 14:05 GMT
Thanks a lot. That worked fine.

> Try calling :
>
> panel.revalidate();
> panel.repaint();
>
> The panel needs to be revalidated to relayout the child components.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.