Results 1 to 8 of 8
Thread: Scroll Bar Issue
- 05-07-2010, 12:55 PM #1
Member
- Join Date
- May 2010
- Posts
- 4
- Rep Power
- 0
Scroll Bar Issue
I hav already got my scrollbars visible in running module but dey r not working i.e. wen i make dem scroll frame is not moving....plz...help me for that..
for visibility i hav code...
class MyAdjustmentListener implements AdjustmentListener {
public void adjustmentValueChanged(AdjustmentEvent e) {
repaint();
}
}
public mainbutton() {
initComponents();
setLayout(new BorderLayout());
JScrollBar hbar = new JScrollBar(
JScrollBar.HORIZONTAL, 30, 20, 0, 300);
JScrollBar vbar = new JScrollBar(
JScrollBar.VERTICAL, 30, 40, 0, 300);
hbar.setUnitIncrement(2);
hbar.setBlockIncrement(1);
hbar.addAdjustmentListener(new MyAdjustmentListener());
vbar.addAdjustmentListener(new MyAdjustmentListener());
add(hbar, BorderLayout.SOUTH);
add(vbar, BorderLayout.EAST);
HELP ME !!!
- 05-07-2010, 01:32 PM #2
Senior Member
- Join Date
- May 2010
- Posts
- 436
- Rep Power
- 4
- 05-07-2010, 01:39 PM #3
Member
- Join Date
- May 2010
- Posts
- 4
- Rep Power
- 0
the code which i have given only fulfills the visibility concept...(by dis code i only get my scrollbars visible on running screen, dey actually are not working when i move them with mouse).
so i am asking how to apply mouse listeners on the scrollbars.
- 05-07-2010, 01:42 PM #4
Senior Member
- Join Date
- May 2010
- Posts
- 436
- Rep Power
- 4
You don't add mouselisteners to JScrollBars and you usually don't use scroll bars in this way. You probably want to use a JScrollPane instead. My recommendation is that you read the Sun Swing tutorial on JScrollPanes as this will likely answer all your questions.
- 05-07-2010, 01:51 PM #5
Member
- Join Date
- May 2010
- Posts
- 4
- Rep Power
- 0
i have read all that stuff but i m not getting it..
if you can give me some idea about it...then it will be easier for me to understand when i will read tutorial again.
- 05-07-2010, 02:00 PM #6
Senior Member
- Join Date
- May 2010
- Posts
- 436
- Rep Power
- 4
What about it don't you get? They would explain things much better than I can. All I can tell you is to create a JScrollPane, place your JPanel inside its viewport, make sure that the JPanel is larger than the JScrollPane, and it should work. Also:
1) Ditch the netbeans code-generation as it's hampering your ability to use Swing (this is not your fault but a general problem with using NetBeans before one is familiar with Swing)
2) Go through most of the Sun tutorials on Swing coding to get familiar with how it works.
3) When you know more about Swing, then NetBeans code generation is fine for quick and dirty GUI creation.
- 05-07-2010, 02:17 PM #7
Member
- Join Date
- May 2010
- Posts
- 4
- Rep Power
- 0
okkk...thnx
- 05-09-2010, 02:27 PM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
@OP, if you could explain your question bit more clearly it's much better. Don't worry about that you are not capable of doing it, let them know in very simple words as much as clearly.
Just alone, you cannot use scroll bars in Java, you have to deals with scroll panes as well. I think it's better to go through the following page first of all, try out all the examples there.
How to Use Scroll Panes (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
Similar Threads
-
Focus scroll bar
By BlackTea in forum SWT / JFaceReplies: 0Last Post: 02-25-2010, 06:16 PM -
CheckBoxTreeViewer and Scroll
By steve.hookway in forum SWT / JFaceReplies: 1Last Post: 11-24-2009, 09:03 PM -
smooth-scroll
By designer in forum Java AppletsReplies: 1Last Post: 07-21-2009, 07:10 PM -
problem with scroll bar
By r.gnanaprakasam in forum AWT / SwingReplies: 0Last Post: 04-22-2009, 01:24 PM -
Scroll message
By getkiran in forum Java AppletsReplies: 1Last Post: 03-05-2009, 04:29 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks