Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Java - JScrollPane (changing up/down button size)

  • 11-08-2006 12:09PM
    #1
    Registered Users, Registered Users 2 Posts: 821 ✭✭✭


    Hi,

    I am using JScrollPane for a TouchScreen program and I want to make the up/down arrow buttons bigger (so they can be more easily pressed).

    I have tried increasing the size of the vertical scroll bar and that does increase the width of the up arrow, but not the height.

    I have also made my own up and down arrow buttons to the side of the scrollbar which, when pressed, call something like: scrollbar.setValue(scrollbar.getValue() + scrollbar.getUnitIncrement()) but the viewport image gets a bit distorted (you know how scrolling in java and JLists,etc. do!) and the scrolling is all jumpy.

    Any suggestions?


Comments

  • Registered Users, Registered Users 2 Posts: 821 ✭✭✭Dr Pepper


    Ok, I eventually figured this out. So, just in case anyone is looking for this in the future, here it is:

    I made a class called MyBasicScrollBarUI which extends BasicScrollBarUI. In this class I have an empty constructor and I over-ride the methods createIncreaseButton and createDecreaseButton. These just create the up and down arrow buttons and return them so I have created my own and returned them instead. I have used MyBasicScrollBarUI in my code like this:
    JTextArea JTA;
    JScrollPane JSP;
    JScrollBar JSB;
    MyBasicScrollBarUI ui;
    
    JTA = new JTextArea();
    JSP = new JScrollPane(JTA);
    JSP.setPreferredSize(new Dimension(800,500));
    JSB = JSP.getVerticalScrollBar();
    JSB.setPreferredSize(new Dimension(60,500));
    ui = new MyBasicScrollBarUI();
    JSB.setUI(ui);
    etc....
    


Advertisement