• 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

Cannot see two Jtables until resize

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey guys,
I am running into a problem and i need help, i basically have a jframe with two JPanels which would hold the JScrollpanes of jtables, there are also two JTextFields who would act as a search bar for populating the the Jtable, the programming of data is done correctly but i am running into a problem, the second Jtable does not show until and unless i resize the jframe window, i cant get it to work. I have tried validate(), update(), setvisible() but it wont work,

Please guys i need your help.

I have add screenshots for reference and the code i given below:


Thanks.



before.PNG
[Thumbnail for before.PNG]
Before Resize
after.PNG
[Thumbnail for after.PNG]
After Resize
 
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
You are making it extremely difficult for us to help you:

1) The code has lot of empty lines. This is a waste of space and makes it difficult for us to read code by going up and down. Whn didn't you remove them when you posted?
2) You should provide a SSCCE for us to help you. You have not done that. You have included JDBC stuff for which we don't have that setup and niether are we interested in setting that up on our machines.
3) The code itself has several problems. Out of the 300 lines, the main() method has 250 lines. This is bad programming. You should have the class extend JPanel or JFrame and add all the GUI stuff in the constructor or a method. The main method should just create the instance or JFrame and show it (and this should be done inside invokeLater).
4) I don't think you have provided us the complete details. Both the tables show up only when the user hits the respective 'search' buttons, isn't it? why haven't you told us about that? You have to tell the details
5) When you add a component at runtime after the frame is visible (which happens when you click the buttons for the first time), you should call revalidate() and repaint() - you have called only repaint().
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Containers with null layout(s) are always bad news.
Recommended reading http://docs.oracle.com/javase/tutorial/uiswing/layout/using.html

For a scrollable table, I would recommend a BorderLayout with the JScrollPane added to the Center
 
Haris Tasawar
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am sorry for the bad programming, its just that i didnt had it in mind when i was creating the project, i would surely re implement the code using different classes for sure, from next time i would make sure that i used proper formatting of the post.... Sorry about that, anyways i would do the revalidate and let you guys know
 
Haris Tasawar
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and as for the border layout, is is possible to implement two Jtables in the center, maybe it isnt, also i put the Revalidate() method and still i see no table?
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Haris Tasawar wrote:and as for the border layout, is is possible to implement two Jtables in the center, maybe it isnt


It definitely isn't. A BorderLayout only supports up to 5 components, one in each region (north, south, west, east, center). To put two components in the center you must nest them in another control; I suggest either a JSplitPane to allow resizing them, or a JPanel with a GridLayout if they need to have the same sizes.
 
Squanch that. And squanch this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic