java scrollbar

java scrollbar

Scrollbar.VERTICAL, 0, 8, -100, 100); what are each values for?

View Answers

November 20, 2010 at 4:05 PM

Hello Friend,

The code specifies the orientation, initial value of bar, visible amount, and minimum and maximum values.

We are providing you the code through which you can understand easily.

import java.awt.*;
import java.awt.event.*;

public class ScrollbarExample extends Panel {
    Label label;
    public ScrollbarExample() {
        label=new Label();
        setLayout(new BorderLayout());
        Scrollbar bar1 = new Scrollbar(Scrollbar.HORIZONTAL, 30, 20, 0, 300);
        Scrollbar bar2 = new Scrollbar(Scrollbar.VERTICAL, 0, 8, -100, 100);
        bar1.setUnitIncrement(2);
        bar1.setBlockIncrement(1);

        bar1.addAdjustmentListener(new Listener());
        bar2.addAdjustmentListener(new Listener());

        add(bar1, BorderLayout.SOUTH);
        add(bar2, BorderLayout.EAST);
        add(label, BorderLayout.CENTER);
         Frame frame = new Frame("Scroll Bar Example");
         frame.add(this);
           frame.setSize(200,200);
        frame.setVisible(true);
    }
      class Listener implements AdjustmentListener {
        public void adjustmentValueChanged(AdjustmentEvent e) {
            label.setText("Value is " + e.getValue() +"");
            repaint();
        }
    }
     public static void main(String s[]) {
     new ScrollbarExample();
     }
}

In the above code using the Scrollbar class we have defined both the bars. In the vertical bar, we have taken your values. When you will run the above code, you will find that vertical bar has the values from -100 to 100. The bar is set to O as initial value and 8 is the visible amount.

Thanks









Related Tutorials/Questions & Answers:
Java Scrollbar
Java Scrollbar   What is the difference between a Scrollbar and a ScrollPane
java scrollbar
java scrollbar  Scrollbar.VERTICAL, 0, 8, -100, 100); what are each values
Advertisements
java program:scrollbar
java program:scrollbar  my program logic is that when i scrolling scrollbar according to that the oval shap is changed by fetching the value of scrollbar the oval is drawn please give me a proper code of this logic
scrollbar
scrollbar  I add a scrollbar to my Frame and its not working
div to scrollbar - Java Beginners
vertical scrollbar. for this i am using a css for that div in which i tried to add overflow:auto but it did not work. and now the only way is in java script so... who replied my answer.  hi, div and scrollbar html
dropdown to vert. scrollbar - Java Beginners
a dropdown into scrollbar when we resize th window in java script  Hi... it on your site!"; messages[6] = "This is good site for Java tutorial"; function... Information Saves space Java javaScript Spring Java Tutorial Struts Simple
vertical scrollbar but without a horizontal scrollbar
vertical scrollbar but without a horizontal scrollbar  How do I make a frame with a vertical scrollbar but without a horizontal scrollbar
Horizontal Scrollbar
Horizontal Scrollbar  How can I implement a horizontal scrollbar
Scrollbar
Scrollbar       A scrollbar is represented by a "slider" widget. The characteristics of it are specified by integer values which are being set at the time of scrollbar
frame with a vertical scrollbar but without a horizontal scrollbar.
frame with a vertical scrollbar but without a horizontal scrollbar.  How do I make a frame with a vertical scrollbar but without a horizontal scrollbar
Horizontal Scrollbar
Horizontal Scrollbar  I am creating a JSF project that has a print("<af:table/>"); the table is too wide to display in the browser. I was wondering if there was anyway to implement a horizontal scrollbar in this table so
scrollbar - applet - Applet
scrollbar - applet  Hi!! It is the program for a vertical scroll bar and the output is (small vertical scrollbar). Suppose if I want a lengthy... ScrollbarDemo extends Applet { public void init() { Scrollbar sb = new
scrollbar in JPanel
scrollbar in JPanel  Scroll bar is not working when i am using the panel layout is null. If i change the panel layout to flow or grid its working. I..., JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);f.add(s
menu with scrollbar
menu with scrollbar  I want to use MenuBar with Scrollbar. I tried it. I dont know how to do it. so please help me. The program should be.... 1.add JScrollPane into the panel. 2.Panel layout should be null. 3.Use menubar 4.Each
CSS ScrollBar Properties
CSS ScrollBar Properties  How can i set ScrollBar properties in CSS? I am using HTML, CSS and Div in my code. Thanks!!   overflow: scroll; overflow-y: scroll; overflow-x: scroll; overflow:-moz-scrollbars-vertical
Scrollbar problem with struts <layout:collection>
Scrollbar problem with struts   How activate the vertical scrollbar in struts in mozilla firefox
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when... it shows the scrollbar but do not show the scrolling tabs here is my code pls do help
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when... it shows the scrollbar but do not show the scrolling tabs here is my code pls do help
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when... it shows the scrollbar but do not show the scrolling tabs here is my code pls do help
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when... it shows the scrollbar but do not show the scrolling tabs here is my code pls do help
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when... it shows the scrollbar but do not show the scrolling tabs here is my code pls do help
Visibal Certical scrollbar with struts collection layout.
Visibal Certical scrollbar with struts collection layout.  how to Visibal Vertical scroll bar with struts collection layout
Scrollbar click in safari browser not Collapsing opened dropdowns
Scrollbar click in safari browser not Collapsing opened dropdowns  When im clicking on the scrollbar in safari browser the click not collapsing the opened dropdowns....i mean if iam scrolling the scrollbars after content is being
How set the height of Thumb in Vertical scrollbar..?
How set the height of Thumb in Vertical scrollbar..?  I have created a Vertical scrollbar. I have removed up arrow and down arrow. also i have changed the skin of thumb by including an image to it. I want the size of thumb same
Flex scrollbar control
Flex ScrollBar Control:- If the user handles data that are displayed but data is too much and not fit in the display area then the user use ScrollBar... the button depends on the current state of the ScrollBar controls. If user Example
How to Collapse Dropdowns on mouseclick on scrollbar in Safari Browser using javascript
How to Collapse Dropdowns on mouseclick on scrollbar in Safari Browser using javascript  How to Collapse Dropdowns on mouseclick on scrollbar in Safari Browser using javascript
in my project, i have to add only vertical scrollbar to a panel,but not horizontal scrollbar. i need some example on it,how to doit.
in my project, i have to add only vertical scrollbar to a panel,but not horizontal scrollbar. i need some example on it,how to doit.  in my project, i have to add only vertical scrollbar to a panel,but not horizontal scrollbar
Fix Scrollbar position in a checkboxList after postback
Fix Scrollbar position in a checkboxList after postback  Hi, I have a CheckBoxList in which have lot of items and i set AutoPostBack="True".I am using Scrollbar on this list.Now when I am checking any item then after postback
how i can add an horizontal scrollbar at my PdfAnnotation ? - JSP-Servlet
how i can add an horizontal scrollbar at my PdfAnnotation ?  How to add the an horizontal scrollbar at my PdfAnnotation ? for example document d=new document(0. document.open
How to get Scrollbar value of textarea in html? - Design concepts & design patterns
How to get Scrollbar value of textarea in html?  Hi All, I have one registration page with terms & policy in read only textarea (Html input tag type). Requirement: Till user didn't scroll down textarea at the last line
how to add the scrollbar to the pdf page when generating the pdf file from jsp - JSP-Servlet
how to add the scrollbar to the pdf page when generating the pdf file from jsp  I am not able to see all the columns when i generated the pdf file from jsp.i have 12 colums so how to add the scrollbar
Create Scroll Bar in Java using SWT
a package org.eclipse.swt.widgets, which is used to create ScrollBar in Java... Create Scroll Bar in Java using SWT       This section is all about creating scroll bar in Java
java - Applet
java  how to connect database table with scrollbar in java applet
java - Applet
java  how to connect database table with scrollbar in java applet
JScrollBar - Java Beginners
java.awt.event.*; import javax.swing.*; public class IMPL_ScrollBar implements...; JLabel lb1; public IMPL_ScrollBar() { frame = new JFrame("This is a scrollbar...("Hello"); } public static void main(String[] args) { IMPL_ScrollBar sb
Show the Value of Scroll Bar in Java Swing
class which is used to handle the vertical scrollbar of Java Swing. This method returns the vertical scrollbar object in the JScrollPane component of Java Swing... Show the Value of Scroll Bar in Java Swing   
java GUI program - Java Beginners
java GUI program  java program that creates the following GUI, when..., JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS...://www.roseindia.net/java/ Thanks. Amardeep
Core Java Interview Question, Interview Question
Core Java Interview Question Page 22  ...: A compilation unit is a Java source code file. ADS_TO_REPLACE_1 Question: What... is the difference between a Scrollbar and a ScrollPane? Answer: A Scrollbar is a Component
core java - Java Beginners
)); Scrollbar sb = new Scrollbar(Scrollbar.HORIZONTAL,2,2,10,40); panel2.add(sb..., ActionListener { Scrollbar sb; int shape, size
Event Handling In Java
Event Handling In Java In this section you will learn about how to handle events in Java. Events in any programming language specifies the external effects... received from the network or it may be something else. In Java when you works
Java Interview Questions - Page 11
Java Interview Questions - Page 11   ... Question: What is the difference between a Scrollbar and a ScrollPane? Answer: A Scrollbar is a Component, but not a Container. A ScrollPane
Core Java Interview Question, Interview Question
Core Java Interview Question Page 15  ..., Button, Canvas, Checkbox, Choice, Container, Label, List, Scrollbar... to the Java runtime system. Question: How many times may an object's finalize
Sitemap Java Swing Tutorial
java persistence example with Maven2 | JPA Locate Function | JPA Length... Parameter | JPA One-to-One Relationship | JPA-QL Queries Java Swing Tutorial Section Java Swing Introduction | Java 2D API | Data Transfer
color change
color change  how to change the color in circle using scrollbar
Java Swing Tutorials
Java Swing Tutorials       Java Swing tutorials -  Here you will find many Java Swing... and you can use it in your program. Java Swing tutorials first gives you brief
Java AWT Package Example
Java AWT Package Example       In this section you will learn about the AWT package of the Java... A class library is provided by the Java programming language which is known
Displaying the same image in a JPanel and using scroll - HELP - Java Beginners
(drawingPane, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR
Text File I/O - DVD.java - Java Beginners
(textPane); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR
JTable Display Data From MySQL Database
. Here you will read about how to create a table in Java swing, how can you add... table in Java ?ADS_TO_REPLACE_1 To create a table in Java Swing we will use... to create an instance of table in Java. javax.swing.table.DefaultTableModel
What is AWT in java
What is AWT in java      ... the native system input events and it automatically test the java platform implementations.  Scrollbar This class provide the user interface

Ads