Results 1 to 6 of 6

Thread: Confused about Scrollbar class

  1. #1
    Join Date
    Jan 2010
    Posts
    70

    Confused about Scrollbar class

    Hello guys,

    I need you help to get solution over my java related query. I have to use Scrollbar class in my java project. But unfortunately I don't have enough knowledge about the 'Scrollbar class'. I have referred many java reference books , but didn't get enough details. I wonder if you let me know something about the Scrollbar class along with proper example code. I am waiting for your reply.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: Confused about Scrollbar class

    The Scrollbar class embodies a scroll bar, a familiar user-interface object. A scroll bar provides a convenient means for allowing a user to select from a range of values. Normally, the user changes the value of the scroll bar by making a gesture with the mouse. For example, the user can drag the scroll bar's bubble up and down, or click in the scroll bar's unit increment or block increment areas. Keyboard gestures can also be mapped to the scroll bar. By convention, the Page Up and Page Down keys are equivalent to clicking in the scroll bar's block increment and block decrement areas.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Confused about Scrollbar class

    Hi,

    Please review below example of Scrollbar class:
    Code:
    import java.awt.BorderLayout;
    java.awt.Scrollbar;
    import java.awt.event.AdjustmentListener;
    
    public class ScrollbarDM extends 
    {  JLabel label;
      public SwingScrollBarExample() {
        super(true);
        label = new JLabel();
        setLayout(new BorderLayout());
        JScrollBar hbar1 = new JScrollBar(JScrollBar.HORIZONTAL, 30, 20, 0, 300);
        hbar1.setUnitIncrement(2);
        hbar1.setBlockIncrement(1);
        hbar1.addAdjustmentListener(new MyAdjustmentListener());
        add(hbar1, BorderLayout.SOUTH);
        }
      class MyAdjustmentListener implements AdjustmentListener {
        public void adjustmentValueChanged(AdjustmentEvent e) {
          label.setText(" New Value is " + e.getValue() + "      ");
          repaint();
        }  }
      public static void main(String sgt[]) {
        JFrame frameC = new JFrame("Scroll Bar Example");
        frameC.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frameC.setSize(300, 200);
        frameC.setVisible(true);
      }
    }

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

    Re: Confused about Scrollbar class

    Hello friends,

    Below I have given some methods of Scrollbar class along with their parameters:
    • setVisibleAmount(int newAmt)
    • setValues(int val, int visible, int min1, int max1)
    • setValueIsAdjusting(boolean bln)
    • setUnitIncrement(int val)
    • setOrientation(int ortn)

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

    Re: Confused about Scrollbar class

    Example of Scrollbar class of java language:
    Code:
    java.awt.Scrollbar
    import java.awt.BorderLayout;
    import javax.swing.JFrame;
    
    public class ScrollBarSample
     {
      public static void main(String argsf[]) 
    {
        JScrollBar oneJScrollBar1 = new JScrollBar(JScrollBar.HORIZONTAL);
        String title1 = (args.length == 0 ? "ScrollBar Sample" : args[0]);
        JFrame frame01 = new JFrame(title);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container contentPane = frame01.getContentPane();
        contentPane.add(oneJScrollBar, BorderLayout.NORTH);
        frame01.setSize(300, 44);
        frame01.setVisible(true);
      }
    }

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

    Re: Confused about Scrollbar class

    Hi friend,

    There are total four nested class available with Scrollbar class, and which are mentioned below:

    * Scrollbar.AccessibleAWTScrollBar
    * Component.FlipBufferStrategy
    * Component.AccessibleAWTComponen
    * Component.BltBufferStrategy

Similar Threads

  1. Confused with DefaultListModel class
    By Khan Baba in forum Software Development
    Replies: 4
    Last Post: 19-02-2010, 12:29 PM
  2. Confused about JApplet class
    By ScarFace 01 in forum Software Development
    Replies: 5
    Last Post: 19-02-2010, 08:50 AM
  3. Confused with JPopupMenu class
    By Bottlenecked in forum Software Development
    Replies: 5
    Last Post: 16-02-2010, 09:27 AM
  4. Confused about JTabbedPane class
    By Sonam Goenka in forum Software Development
    Replies: 5
    Last Post: 13-02-2010, 02:20 PM
  5. Confused with OverlayLayout class
    By Bottlenecked in forum Software Development
    Replies: 5
    Last Post: 12-02-2010, 09:37 AM

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,714,053,550.13345 seconds with 17 queries