0

Hi,
I have been working on a ScrollPane and I need to increase the increments (when you press the up and down arrow), and also make it respond to a mouse scroll wheel.

The code I have (one screen in a CardLayout) is:

public void instructions ()
    {
        resize (800, 680);

        instructions = new Panel ();

        JLabel title = new JLabel (createImageIcon ("images//instructionstitle.jpg"));
        JTextArea objective = new JTextArea ("Objective:");

        ScrollPane scrollPane = new ScrollPane ();
        //scrollPane = new ScrollPane (ScrollPane.SCROLLBARS_AS_NEEDED);
        scrollPane.setSize (new Dimension (800, 670));
        scrollPane.add (title);

        instructions.add (scrollPane);
        screens.add ("2", instructions);
    }

I am thinking I need to use one of the mouse event handlers, and maybe create additional methods?

Thank you.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by quuba
0

use :

JScrollPane scrollPane; //do not mix swing with awt ScrollPane
scrollPane.setWheelScrollingEnabled(true);//usefull method

about JScrollPane read in java tutorial

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.