This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
So, I build an Applet with text areas, button JcomboBoxes, etc. I put all these components in a JPanel called jPanel1. At the end I pop the panel on the container and everything worked great until I decided to have a selection from a JComboBox place one component, a JTable, on the panel.(Before I was just placing it directly on there without user input). It appears to remove the old component (a JScrollPane) but the table never shows. What do I need to do? see code snippets below
I do not wish to seem ungrateful, I appreciate someone taking the time to answer. Thank you Craig but� I do not think the answer provided can be used in this case. The reason is that the tables (2 of them) have 10 columns and ,in worse case, 6000 rows (on average just around 1000) This would mean possibly storing 120,000 JTables. Even if the clients machine could handle this I don�t think it would be the best approach. I should have given more details when I first posted. My apologies. I am implementing the code found on Sun�s web-site: http://java.sun.com/docs/books/tutorial/uiswing/components/table.html It seems to work great after modifying it to take the data from a database based on user selection in the applet. I just can�t seem to get it to appear in the beginning. If I build all my components from the start and populate the table with a hard coded selection so that when the entire container is started it knows to place a table at a certain location then everything works great. I can sort and re-sort. If I draw everything from the beginning except the table and wait on the user to put in the parameters for the table then�.not so good It seems to remove the component that I put in as a place holder for the table (a JscrollPane) but the table never appears. Again, Thank you Craig for your input but if you, are someone else, could re-examine the issue with this new information I would appreciate it.
If I draw everything from the beginning except the table and wait on the user to put in the parameters for the table then�.not so good
Joined: Feb 04, 2005
Update...disregard and thanks for the help. In backtracking to get back to the original code I fixed it so it does what I need it to now.
If you add a component to a container after that container is physically visible on the screen, then you must call validate() on that container to force it to be laid out again, or the new component won't show up. Perhaps that's the problem you're having?
Ernest, you are a saint. After I thought I had fixed it I realized that it still wasn't working correctly. I was embarrassed to come back and admit it but then I saw your post. That seems to be the problem. Thanks for the tip on validate. I was using repaint and not getting anywhere.
Joined: Feb 04, 2005
Hmmm, the table shows in a scrollPane but I can't use the scrollPane. Anythoughts on why or what would cause it?