• Post Reply Bookmark Topic Watch Topic
  • New Topic

Custom Objects and JScrollpane  RSS feed

 
Andrew Zahra
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to get the Vector Visuals library to work with a JScrollPane. However I don't understand how the object to be scrolled reports its size to the scrollpane.

I have tried calling setModel directly on the horizontal scrollbar as an experiment, but the scrollbar still shows as if there is no scrolling required.

Ultimately I want to make the scrollpane move a viewport around the vector world that vector visuals is rendering, but I can't get past this initial step.

How does the object to be scrolled report its actual size to the JScrollPane?
 
Torgil Zethson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does the object to be scrolled report its actual size to the JScrollPane?


Two alternatives:

1. By implementing the javax.swing.Scrollable interface;
or
2. By its getPreferredSize() method.

The first case is used by components such as JTable, JTree, and JTextArea.
The second is used, for instance, when you place a JPanel in a JScrollPane. The scrollpane will use the preferred size of the panel to decide if scrolling is needed or not.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!