This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jscrollpane wont show until i adjust window size with mouse???  RSS feed

 
Kip Bodey
Ranch Hand
Posts: 43
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so for a test i have a small array set as a jlist which is the contents of my jscrollpane, and it appears as if nothing is there until i adjust the window size by dragging it out or in... whats going on?
here is the full code
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that's because you called "setVisible(true)" too early in the setup process. After you call it (at line 37 in your posted code) you go on to modify the UI by adding more components. Usually when you add more components to a GUI which is already visible you have to do something to adjust the GUI to account for them. But in this case I'd say it's sufficient to move the call to setVisible down to the end of the constructor.
 
Kip Bodey
Ranch Hand
Posts: 43
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you... you're the man i didn't even think about that
 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shall move this discussion to our GUIs forum. I shall also amend that long comment which makes the page hard to read.

Agree with PC. Always call setVisible last. Otherwise you would have to call revalidate() or similar on your Frame. There is a section about scroll panes in the Java Tutorials.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!