• 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

Get Reference of JScrollPane from JPanel

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have added a JScrollPane and added a JPanel to JscrollPane. How can I get reference to Jscrollpane from the JPanel in order to access properties of Jscrollpane?
 
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
This is kind of odd. What properties are you trying to access? What problem are you trying to solve?
 
Himanshu sGarg
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want that the buttons added to Jpanel inside jscrollpane should move while I scroll the Jscrollpane, i.e. the buttons in jpanel should always be visible while I scroll the scrollpane.
 
Maneesh Godbole
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
This can be done in (minimum) two ways
1) Create a panel with BorderLayout
2) Add scrollable content to the scroll pane
3) Add scroll pane to center of panel in #1 above
4) Add buttons to North, South, East, West of panel #1 above as per design.
This way, even if the content scrolls, your buttons dont.

The other way would be to pass to declare the scroll pane as an instance variable. Can you show us your panel code which has the scroll pane added to it?
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
5) Set a columnHeaderView
6) Set a rowHeaderView

Himanshu, I suspect that you are mucking around with a null layout and setBounds(...). Don't. Use a proper layout manager or a combination of them.
 
Maneesh Godbole
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
Oh wow! I agree Darryl has the better solution. I had completely forgotten about the column header
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not necessarily a better solution, and may not be acceptable of both the H- and V-scrollbars are active. The column header scrolls horizontally, and the row header scrolls vertically to sync with the viewportView.
 
reply
    Bookmark Topic Watch Topic
  • New Topic