Post Reply 
PrefuseJScrollPane demo
16-08-2008, 11:22 AM
Post: #1
PrefuseJScrollPane demo
Ever wanted prefuse to have scrollbars?

I thought: dragging with mouse is so cool, I don“t need that.
But as soon as I embedded prefuse with my swing gui I thought: hm scrollbars would be nice.

So here is my first version of a "scrollpane emulator" for prefuse.
If you find bugs feel free to contact me or correct them (where I would appreciate it if you would post that here).

You can create the pane like that:
Code:
m_scrollPane = new PrefuseJScrollPane(m_display);
Then simply add the pane to your container and have months of fun scrolling around Wink


.java  PrefuseJScrollPane.java (Size: 19.31 KB / Downloads: 222)
Find all posts by this user
Quote this message in a reply
18-08-2008, 02:40 PM
Post: #2
RE: PrefuseJScrollPane demo
I made some smaller changes

- Rounding could lead to flickering scrollbars when zooming and graph fits on screen
- Somehow the scrollbars started to show wrong behavior when dragging graph out of the pane


.java  PrefuseJScrollPane.java (Size: 19.62 KB / Downloads: 251)
Find all posts by this user
Quote this message in a reply
14-01-2010, 04:36 PM
Post: #3
RE: PrefuseJScrollPane demo
Nice ! Thank you.

Using BorderLayout instead of GridbagLayout makes the PrefuseJScrollPane fill the entire space available for it, which is not the case with GridbadLayout.

Apart for the initialize() method where one obviously needs to replace setLayout(new GridBagLayout()) by setLayout(new BorderLayout()), only the addDisplay(Display display) method must be changed into this :

Code:
public void addDisplay(Display display) {

        // Initially the scrollbars are not yet added to the layout
        if (this.m_display != null) {

            // If there was an old display, remove it from the pane
            remove(this.m_display);
        } else {
            add(barV,BorderLayout.EAST);
            add(barH,BorderLayout.SOUTH);
        }

        this.m_display = display;

        // Add the paint listener that notifies us when the pane is repainted
        this.m_display.addPaintListener(new DisplayPaintListener(this));

        add(this.m_display,BorderLayout.CENTER);

        // Fit the scrollbars
        checkScrollbarState();
    }
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: