Results 1 to 5 of 5
Thread: Regarding JButton
- 02-18-2011, 01:24 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 3
- Rep Power
- 0
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
- 02-18-2011, 01:36 PM #2
Member
- Join Date
- Feb 2011
- Posts
- 7
- Rep Power
- 0
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.
- 02-18-2011, 01:59 PM #3
Member
- Join Date
- Feb 2011
- Posts
- 3
- Rep Power
- 0
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;
}
- 02-18-2011, 02:03 PM #4
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
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
- 02-18-2011, 02:17 PM #5
Member
- Join Date
- Feb 2011
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
JButton help
By ThrashingBoy in forum New To JavaReplies: 8Last Post: 03-01-2011, 01:48 AM -
JButton help
By ThrashingBoy in forum New To JavaReplies: 2Last Post: 01-29-2011, 12:39 PM -
JButton Help
By ravjot28 in forum AWT / SwingReplies: 2Last Post: 01-17-2010, 01:07 PM -
JButton help :)
By yasmin k in forum AWT / SwingReplies: 7Last Post: 11-12-2009, 09:53 PM -
Help with JButton
By geoffreybarwise in forum New To JavaReplies: 4Last Post: 05-21-2008, 10:48 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks