Java know how much (92) scroll bar

Source: Internet
Author: User

A scrollbar (Jscrollbar), also known as a slider, is used to represent a relative value that represents an integer in the specified range. For example, when you edit a document in Word, the slider to the right of the edit window corresponds to the position of the current edit position in the entire document, and you can move to select a new edit location. In swing, the Jscrollbar class is used to implement and manage the adjustable interface. The common construction methods of the Jscrollbar class are:
Jscrollbar (int dir,int init,int width,int low,int High)
Where dir indicates the direction of the scroll bar. The Jscrollbar class defines two constants, jscrollbar.vertical represents a vertical scrollbar, and jscrollbar.horizontal represents a horizontal scroll bar. Init represents the initial value of the ScrollBar, which determines the position at which the ScrollBar slider starts, the width of the scrollbar slider, and the last two parameters that specify the lower and upper bounds of the scroll bar. Note the width of the slider may affect the actual maximum value that can be obtained by the scroll bar. For example, the scroll bar range is 0 to 255, the width of the slider is 10, and the left or top edge of the slider is used to determine its actual position. The maximum value that the scroll bar can reach is the specified maximum value minus the width of the slider. Therefore, the value of the scroll bar will not exceed 245.

Other common methods of the Jscrollbar class are:

    1. Setunitincrement (): Sets the increment, that is, the increment of unit pixels;
    2. Getunitincrement (): Gets the increment;
    3. Setblockincrement (): Sets the increment of the slider, that is, the amplitude of the slider;
    4. Getblockincrement (): Gets the slider increment;
    5. Setmaxinum (): Sets the maximum value;
    6. Getmaxinum (): Gets the maximum value;
    7. Setmininum (): Sets the minimum value;
    8. Getmininum (): Gets the minimum value;
    9. SetValue (): Sets the new value;
    10. GetValue (): Gets the current value.


The event type of the Jscrollbar class object is adjustmentevent; The interface to be implemented by the class is Adjustmentlistener, and the interface method is adjustmentvaluechanged (); The method to register the monitor is Addadjustmentlistener (); The method to get the event source object is Getadjustable ().

The method defined by the Myscrollbar class Getpreferedsize () is also a method defined in the component class, and the interface component determines the size of the interface component by overriding the method that defines it. When the layout word processor arranges the component layout, it calls the method to determine the size of the component. This method returns an object of type dimension, with a dimension object containing two integers, the width and height of the component.

Series Articles:

Java know how much (top)Java know how much (medium)Java knows how many () Java vectors (vector) and their applicationsJava know how much (79) hash table and its applicationJava know how much (80) graphical Interface design basicsJava know how much (81) frame window BasicsJava know how much (82) Introduction to tags, buttons, and button eventsJava know how much (83) Panel Basics: JPanel and JScrollPaneJava know how much (84) layout design of graphical interfaceJava know how much (85) text box and text areaJava know how much (86) input and output of text box and text areaJava know how much (87) Select boxes and radio buttonsJava know how many (88) lists and combo boxesJava know how many (89) lists and combo boxesJava know how much (90) menuJava know how much (91) dialog box

Java know how much (92) scroll bar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.