Results 1 to 5 of 5
  1. #1
    sneha_v27 is offline Member
    Join Date
    Feb 2011
    Posts
    3
    Rep Power
    0

    Question Regarding JButton

    I have a JScroll Pane in a page . I have disaibled it .

    Now problem is i have placed Two buttons , Instead of scrolling i want to use those two buttons and want to Scroll up and down (not by JScroll Pane )

    I dont know wat to put in the Action event handler of that UP button And Down Button ..
    Can Any one help me regarding this

    Thanks In advance

  2. #2
    javaforum$ is offline Member
    Join Date
    Feb 2011
    Posts
    7
    Rep Power
    0

    Default Move/Set Cursor Position

    Get the current position of cursor/pointer say pt(x,y) and move the pointer to say pt(x+100,y+100) | pt(x-100,y-100) w.r.t up/down buttons.
    But make sure the positions are moved appropriately.

  3. #3
    sneha_v27 is offline Member
    Join Date
    Feb 2011
    Posts
    3
    Rep Power
    0

    Default

    Sorry didnt get u.
    I have two buttons .
    one is UP
    And another Down .

    I have to write a code in Action event handler such that when i click on up button the contents in the JPanel should scoll up and down.


    private ActionListener getUpActionListener() {

    if (up == null) {
    class b11ActionListener implements ActionListener {

    public void actionPerformed(ActionEvent b2e) {
    (What i have to write here) .. ??

    }
    }

    up = new b11ActionListener();

    }


    return up;
    }

  4. #4
    eRaaaa is online now Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    5

    Default

    I would use the JScrollPane anymore, but maybe with setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SC ROLLBAR_NEVER);
    In your listener of the buttons you could use then e.g.

    JScrollBar bar = pane.getVerticalScrollBar(); //pane = your scroll pane
    bar.setValue(bar.getValue()-5); // - = up, + = down

  5. #5
    sneha_v27 is offline Member
    Join Date
    Feb 2011
    Posts
    3
    Rep Power
    0

    Default

    Sorry didnt worked ... i am not getting those methods get vertical scroll bar

Similar Threads

  1. JButton help
    By ThrashingBoy in forum New To Java
    Replies: 8
    Last Post: 03-01-2011, 01:48 AM
  2. JButton help
    By ThrashingBoy in forum New To Java
    Replies: 2
    Last Post: 01-29-2011, 12:39 PM
  3. JButton Help
    By ravjot28 in forum AWT / Swing
    Replies: 2
    Last Post: 01-17-2010, 01:07 PM
  4. JButton help :)
    By yasmin k in forum AWT / Swing
    Replies: 7
    Last Post: 11-12-2009, 09:53 PM
  5. Help with JButton
    By geoffreybarwise in forum New To Java
    Replies: 4
    Last Post: 05-21-2008, 10:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •