Results 1 to 8 of 8
  1. #1
    vils11111 is offline Member
    Join Date
    May 2010
    Posts
    4
    Rep Power
    0

    Default 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 !!!

  2. #2
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    4

    Default

    Quote Originally Posted by vils11111 View Post
    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...
    For many here English is not a native language. If you are serious about needing help, please be serious with your language, translate the above to standard English, and help us to better understand you.

  3. #3
    vils11111 is offline Member
    Join Date
    May 2010
    Posts
    4
    Rep Power
    0

    Default

    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.

  4. #4
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    4

    Default

    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.

  5. #5
    vils11111 is offline Member
    Join Date
    May 2010
    Posts
    4
    Rep Power
    0

    Default

    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.

  6. #6
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    4

    Default

    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.

  7. #7
    vils11111 is offline Member
    Join Date
    May 2010
    Posts
    4
    Rep Power
    0

    Default

    okkk...thnx

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    @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

  1. Focus scroll bar
    By BlackTea in forum SWT / JFace
    Replies: 0
    Last Post: 02-25-2010, 06:16 PM
  2. CheckBoxTreeViewer and Scroll
    By steve.hookway in forum SWT / JFace
    Replies: 1
    Last Post: 11-24-2009, 09:03 PM
  3. smooth-scroll
    By designer in forum Java Applets
    Replies: 1
    Last Post: 07-21-2009, 07:10 PM
  4. problem with scroll bar
    By r.gnanaprakasam in forum AWT / Swing
    Replies: 0
    Last Post: 04-22-2009, 01:24 PM
  5. Scroll message
    By getkiran in forum Java Applets
    Replies: 1
    Last Post: 03-05-2009, 04:29 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
  •