Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Java - JScrollPane (changing up/down button size)

  • 11-08-2006 11:09am
    #1
    Registered Users, Registered Users 2 Posts: 841 ✭✭✭


    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: 841 ✭✭✭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