Results 1 to 7 of 7

Thread: How to use JScrollBar class?

  1. #1
    Join Date
    Dec 2009
    Posts
    41

    How to use JScrollBar class?

    Hello Guys,

    I am new to the java programming. I am getting trouble while understanding the concept of 'JScrollBar class'. So need I need your help to be aware about the functionality of JScrollBar class of java. I also want be aware about the constructors and methods of JScrollBar class. If you have enough knowledge about the JScrollBar class of java, then please let me know the same. Your any help over JScrollBar class will be greatly appreciated.

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    Re: How to use JScrollBar class?

    A JScrollBar class used for an implementation of a scrollbar. The user positions the knob in the scrollbar to determine the contents of the viewing area. The program typically adjusts the display so that the end of the scrollbar represents the end of the displayable contents, or 100% of the contents. The start of the scrollbar is the beginning of the displayable contents, or 0%. The position of the knob within those bounds then translates to the corresponding percentage of the displayable contents.

  3. #3
    Join Date
    Apr 2008
    Posts
    1,948

    Re: How to use JScrollBar class?

    Hi,

    Please following example of JScrollBar class of java:
    Code:
    import javax.swing.JScrollBar;
    import java.awt.BorderLayout;
    import javax.swing.JFrame;
    
    public class JScrollBarDM {
      public static void main(String argsn[]) throws Exception {
        JFrame FL = new JFrame();
        FL.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JScrollBar oneJScrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
        FL.add(oneJScrollBar, BorderLayout.NORTH);
        FL.setSize(300, 44);
        FL.setVisible(true);
    
      }
    
    }

  4. #4
    Join Date
    May 2008
    Posts
    2,012

    Re: How to use JScrollBar class?

    Following are some most important methods of the JScrollBar class, please review them carefully:
    1. setVisibleAmount(int extnt)
    2. setValues(int newValue, int newExtnt, int Min, int Max)
    3. setValueIsAdjusting(boolean bl)
    4. setUnitIncrement(int unitIncrmnt)
    5. setOrientation(int orn)
    6. setModel(BoundedRangeModel newMdl)

  5. #5
    Join Date
    Apr 2008
    Posts
    2,005

    Re: How to use JScrollBar class?

    Hello friend,

    Below is the java code which is show you how to use methods of JScrollBar class:
    Code:
    import javax.swing.JScrollBar;
    
    public class JSMainClass {
      public static void main(String argsp[]) throws Exception {
        AdjustmentListener adjustmentListener = new AdjustmentListener() {
          public void adjustmentValueChanged(AdjustmentEvent adjustmentEvent) {
            System.out.println("Adjusted: " + adjustmentEvent.getValue());
          }
        };
        JScrollBar oneJScrollBar1 = new JScrollBar(JScrollBar.HORIZONTAL);
        oneJScrollBar1.addAdjustmentListener(adjustmentListener);
    
        JFrame GW = new JFrame("ScrollBars R Us");
        GW.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        GW.add(oneJScrollBar, BorderLayout.NORTH);
    
        GW.setSize(300, 200);
        GW.setVisible(true);
      }
    
    }

  6. #6
    Join Date
    May 2008
    Posts
    2,297

    Re: How to use JScrollBar class?

    Hi,

    I suggest you to go through following constructors of JScrollBar class:
    • JScrollBar(): This constructor is used for the creation of vertical scrollbar
    • JScrollBar(int ortn):This constructo is used for the creation of scrollbar with a particular specification
    • JScrollBar(int orientation, int val, int extnt, int min1, int max1): This constructor is used for the creation of scrollbar with a particular specification such as max, min.

  7. #7
    Join Date
    Nov 2009
    Posts
    652

    Re: How to use JScrollBar class?

    Following are some nested classes of the JScrollBar class, please review them carefully:
    1. JScrollBar.AccessibleJScrollBar
    2. Component.BltBufferStrategy
    3. JComponent.AccessibleJComponent
    4. Component.AccessibleAWTComponent
    5. Container.AccessibleAWTContainer

Similar Threads

  1. Replies: 8
    Last Post: 08-10-2011, 11:06 PM
  2. What is the difference between Local class and global class in C++?
    By Dëfrim in forum Software Development
    Replies: 4
    Last Post: 03-01-2011, 10:44 PM
  3. Replies: 5
    Last Post: 12-02-2010, 06:23 PM
  4. Ultra solid drives:Imation M-Class and S-Class
    By Regina in forum Portable Devices
    Replies: 1
    Last Post: 03-04-2009, 10:34 AM
  5. Good news for CBSE CLASS X & CLASS IX - visit learnnext
    By surya_expert in forum Education Career and Job Discussions
    Replies: 0
    Last Post: 13-12-2008, 12:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,656,772.30980 seconds with 17 queries