When the user moves the knob on the vertical scroll bar up and down, the visible area of the client moves up and down. Similarly, when the user moves the knob on the horizontal scroll bar to the right and left, the visible area of the client moves back and forth accordingly. The position of the knob relative to its track is proportionally equal to the position of the visible area relative to the client. In the Java look and feel and some others, the size of the knob gives a visual clue as to how much of the client is visible.
By clicking an arrow button, the user can scroll by a unit increment. By clicking within the track, the user can scroll by a block increment. If the user has a mouse with a wheel, then the user can scroll vertically using the mouse wheel. The amount that the mouse wheel scrolls is platform dependent. For example, by default on Windows XP, the mouse wheel scrolls three unit increments; the Mouse control panel allows you to specify a different number of unit increments or to use a block increment instead. More information about unit and block increments is in Implementing a Scrolling-Savvy Client.
Typical programs don't directly instantiate or call methods on a viewport or scroll bar. Instead, programs achieve their scrolling behavior using the JScrollPane API and the API discussed in Implementing a Scrolling-Savvy Client. Some scrolling-savvy components such as JList, JTable, and JTree also provide additional API to help you affect their scrolling behavior.
Setting the Scroll Bar Policy
On startup, the scroll pane in the ScrollDemo application has two scroll bars. If you make the window large, both scroll bars disappear because they are no longer needed. If you then shrink the height of the window without changing its width, the vertical scroll bar reappears. Further experimentation will show that in this application both scroll bars disappear and reappear as needed. This behavior is controlled by the scroll pane's scroll bar policy, Actually, it's two policies: each scroll bar has its own.
ScrollDemo doesn't explicitly set the scroll pane's scroll bar policies — it uses the default. You can set the policies when you create the scroll pane or change them dynamically.
Of the constructors provided by JScrollPane, these two let you set the scroll bar policies when you create the scroll pane:
JScrollPane(Component, int, int)
JScrollPane(int, int)
The first int specifies the policy for the vertical scroll bar; the second specifies the policy for the horizontal scroll bar. You can also set the policies dynamically with the setHorizontalScrollBarPolicy and setVerticalScrollBarPolicy methods. With both the constructors and the methods, use one of the following constants defined in the ScrollPaneConstants interface (which is implemented by JScrollPane):
Policy Description
VERTICAL_SCROLLBAR_AS_NEEDED
HORIZONTAL_SCROLLBAR_AS_NEEDED The default. The scroll bar appears when the viewport is smaller than the client and disappears when the viewport is larger than the client.
VERTICAL_SCROLLBAR_ALWAYS
HORIZONTAL_SCROLLBAR_ALWAYS Always display the scroll bar. The knob disappears if the viewport is large enough to show the whole client.
VERTICAL_SCROLLBAR_NEVER
HORIZONTAL_SCROLLBAR_NEVER Never display the scroll bar. Use this option if you don't want the user to directly control what part of the client is shown, or if you want them to use only non-scroll-bar techniques (such as dragging).
Providing Custom Decorations
The area drawn by a scroll pane consists of up to nine parts: the center, four sides, and four corners. The center is the only component that is always present in all scroll panes. Besides scroll bars, the sides can contain column and row headers. A corner component is visible only if both sides that intersect at that corner contain visible components.
เมื่อผู้ใช้เลื่อนปุ่มบนแถบเลื่อนแนวตั้งขึ้นและลง พื้นที่การมองเห็นของไคลเอ็นต์ย้ายขึ้นและลง ในทำนองเดียวกัน เมื่อผู้ใช้เลื่อนปุ่มบนแถบเลื่อนแนวนอนไปทางขวาและซ้าย พื้นที่การมองเห็นของไคลเอ็นต์ย้ายไปมาตาม ตำแหน่งของปุ่มติดตามความสัมพันธ์เป็นสัดส่วนเท่ากับตำแหน่งของพื้นที่ที่มองเห็นสัมพันธ์กับลูกค้า ในชวาลักษณะและความรู้สึกและบางคนอื่น ๆ ขนาดของปุ่มให้ตั้งใจเป็นจำนวนของไคลเอนต์จะเห็นภาพโดยการคลิกที่ปุ่มลูกศร ผู้ใช้สามารถเลื่อน โดยเพิ่มหน่วย โดยการคลิกภายในติดตาม ผู้ใช้สามารถเลื่อน โดยเพิ่มบล็อก ถ้าผู้ใช้มีเมาส์แบบ มีล้อเลื่อน แล้วผู้ใช้สามารถเลื่อนแนวตั้งโดยใช้ล้อเลื่อนของเมาส์ ยอดเงินที่เลื่อนล้อเลื่อนของเมาส์ขึ้นอยู่กับแพลตฟอร์มได้ ตัวอย่าง ค่าเริ่มต้น Windows XP ล้อเลื่อนของเมาส์เลื่อนสามหน่วยที แผงควบคุมเมาส์ช่วยให้คุณ สามารถระบุจำนวนหน่วยน้อย หรือใช้เพิ่มบล็อกแทน ข้อมูลเพิ่มเติมเกี่ยวกับหน่วยและบล็อกทีได้ใช้ไคลเอนต์ Scrolling เข้าใจโดยทั่วไปโปรแกรมไม่สร้างอินสแตนซ์โดยตรง หรือเรียกวิธีบนช่องมุมมองหรือเลื่อนแถบ แทน โปรแกรมให้เลื่อนลักษณะการทำงานโดยใช้ JScrollPane API และ API ในการใช้งานไคลเอนต์ Scrolling เข้าใจ บางคอมโพเนนต์เลื่อนเข้าใจเช่น JList, JTable และ JTree ยังมี API เพิ่มเติมเพื่อช่วยให้คุณมีผลต่อพฤติกรรมของพวกเขาเลื่อนSetting the Scroll Bar PolicyOn startup, the scroll pane in the ScrollDemo application has two scroll bars. If you make the window large, both scroll bars disappear because they are no longer needed. If you then shrink the height of the window without changing its width, the vertical scroll bar reappears. Further experimentation will show that in this application both scroll bars disappear and reappear as needed. This behavior is controlled by the scroll pane's scroll bar policy, Actually, it's two policies: each scroll bar has its own.ScrollDemo doesn't explicitly set the scroll pane's scroll bar policies — it uses the default. You can set the policies when you create the scroll pane or change them dynamically.Of the constructors provided by JScrollPane, these two let you set the scroll bar policies when you create the scroll pane:JScrollPane(Component, int, int)JScrollPane(int, int)The first int specifies the policy for the vertical scroll bar; the second specifies the policy for the horizontal scroll bar. You can also set the policies dynamically with the setHorizontalScrollBarPolicy and setVerticalScrollBarPolicy methods. With both the constructors and the methods, use one of the following constants defined in the ScrollPaneConstants interface (which is implemented by JScrollPane):Policy DescriptionVERTICAL_SCROLLBAR_AS_NEEDEDHORIZONTAL_SCROLLBAR_AS_NEEDED The default. The scroll bar appears when the viewport is smaller than the client and disappears when the viewport is larger than the client.VERTICAL_SCROLLBAR_ALWAYSHORIZONTAL_SCROLLBAR_ALWAYS Always display the scroll bar. The knob disappears if the viewport is large enough to show the whole client.VERTICAL_SCROLLBAR_NEVERHORIZONTAL_SCROLLBAR_NEVER Never display the scroll bar. Use this option if you don't want the user to directly control what part of the client is shown, or if you want them to use only non-scroll-bar techniques (such as dragging).Providing Custom DecorationsThe area drawn by a scroll pane consists of up to nine parts: the center, four sides, and four corners. The center is the only component that is always present in all scroll panes. Besides scroll bars, the sides can contain column and row headers. A corner component is visible only if both sides that intersect at that corner contain visible components.
การแปล กรุณารอสักครู่..

เมื่อผู้ใช้เลื่อนลูกบิดในแนวตั้งแถบเลื่อนขึ้นและลง พื้นที่การมองเห็นของลูกค้าที่ย้ายขึ้นและลง ในทํานองเดียวกัน เมื่อผู้ใช้เลื่อนแถบเลื่อนแนวนอนลูกบิดบนด้านขวาและซ้าย มองเห็นพื้นที่ของลูกค้าย้ายไปมาตามตำแหน่งของปุ่มที่ญาติของติดตามสัดส่วนเท่ากับตำแหน่งของพื้นที่ที่สัมพันธ์กับลูกค้า ใน Java รูปลักษณ์และความรู้สึกและบางคนอื่น ๆ ขนาดของปุ่มให้เบาะแสภาพเป็นวิธีการมากของลูกค้าสามารถมองเห็นได้
โดยการคลิกลูกศรปุ่มผู้ใช้สามารถเลื่อนโดยหน่วยที่เพิ่มขึ้น โดยการคลิกภายในติดตาม ผู้ใช้สามารถเลื่อนโดยบล็อกเพิ่มขึ้นหากผู้ใช้มีเมาส์ที่มีล้อ จากนั้นผู้ใช้สามารถเลื่อนตามแนวตั้ง การใช้ล้อเมาส์ ยอดเงินที่ล้อเมาส์เลื่อนเป็นแพลตฟอร์มขึ้นอยู่กับ ตัวอย่างเช่น โดยค่าเริ่มต้นใน Windows XP , ล้อเมาส์เลื่อนสามหน่วยเพิ่มขึ้น ; แผงควบคุมเมาส์ช่วยให้คุณสามารถระบุหมายเลขที่แตกต่างกันของหน่วย หรือเพิ่มขึ้นเพื่อใช้บล็อกเพิ่มแทนข้อมูลเพิ่มเติมเกี่ยวกับหน่วยและเพิ่มบล็อกในการเลื่อน เข้าใจลูกค้า โปรแกรมทั่วไป
ไม่โดยตรงยกตัวอย่างหรือเรียกวิธีการบน Viewport หรือเลื่อนบาร์ แทน โปรแกรมบรรลุของพวกเขาเลื่อนพฤติกรรมใช้ jscrollpane API และ API ที่กล่าวถึงในการเลื่อนการเข้าใจลูกค้า บางคอมโพเนนต์ชาญเลื่อน เช่น jlist jtable , ,และ jtree ยังมีเพิ่มเติม API เพื่อช่วยให้คุณกับการเลื่อนพฤติกรรม
การตั้งค่าแถบเลื่อนนโยบาย
เมื่อเริ่มต้นเลื่อนบานหน้าต่างใน scrolldemo โปรแกรมมีสองแถบเลื่อน . ถ้าคุณทำให้หน้าต่างขนาดใหญ่ ทั้งแถบเลื่อนหายไปเพราะพวกเขาจะไม่มีความจำเป็นอีกต่อไป ถ้าคุณลดขนาดความสูงของหน้าต่างโดยไม่ต้องเปลี่ยนความกว้างของแถบเลื่อนแนวตั้งปรากฏขึ้น .การทดลองต่อไปจะแสดงว่า ในโปรแกรมนี้ทั้งแถบเลื่อนหายไป และปรากฏเป็น พฤติกรรมนี้จะถูกควบคุมโดยนโยบาย แถบเลื่อนเลื่อนบานหน้าต่างก็จริง มันเป็นนโยบายที่ 2 แต่ละแถบเลื่อนได้เอง
scrolldemo ไม่ได้อย่างชัดเจนตั้งเลื่อนบานหน้าต่างของแถบเลื่อนนโยบาย - มันใช้ค่าเริ่มต้นคุณสามารถตั้งค่านโยบาย เมื่อคุณสร้างการเลื่อนบานหน้าต่างหรือการเปลี่ยนแปลงแบบไดนามิก
ของผู้รับเหมาโดย jscrollpane สองคนนี้ ให้คุณตั้งค่าแถบเลื่อนนโยบาย เมื่อคุณสร้างการเลื่อนบานหน้าต่าง :
jscrollpane ( ส่วนประกอบ , int , int )
jscrollpane ( int , int )
int ก่อนกำหนดนโยบายสำหรับแถบเลื่อนแนวตั้ง ที่สอง กำหนดนโยบายในแนวนอนแถบเลื่อนนอกจากนี้คุณยังสามารถตั้งค่านโยบายแบบไดนามิกกับ sethorizontalscrollbarpolicy และวิธีการ setverticalscrollbarpolicy . กับทั้งผู้รับเหมาและวิธีการ ใช้หนึ่งของค่าคงที่ที่กำหนดไว้ใน scrollpaneconstants อินเตอร์เฟซดังต่อไปนี้ ( ซึ่งดำเนินการโดย jscrollpane ) :
horizontal_scrollbar_as_needed อธิบายนโยบาย vertical_scrollbar_as_needed เริ่มต้นแถบเลื่อนจะปรากฏขึ้นเมื่อ viewport มีขนาดเล็กกว่าลูกค้า และหายไปเมื่อ Viewport มากกว่าลูกค้า vertical_scrollbar_always
horizontal_scrollbar_always มักจะแสดงแถบเลื่อน . ลูกบิดหายไปถ้า viewport มีขนาดใหญ่พอที่จะให้ลูกค้าทั้งหมด vertical_scrollbar_never
horizontal_scrollbar_never ไม่แสดงแถบเลื่อน .ใช้ตัวเลือกนี้หากคุณไม่ต้องการให้ผู้ใช้สามารถควบคุมได้โดยตรงส่วนใดของลูกค้าจะแสดง , หรือถ้าคุณต้องการใช้เท่านั้น ไม่เลื่อนบาร์เทคนิค ( เช่นลาก )
ให้ตกแต่งเองพื้นที่วาดโดยเลื่อนบานหน้าต่างประกอบด้วยถึงเก้าส่วน ศูนย์ สี่ด้าน และสี่มุม ศูนย์เป็นเพียงส่วนประกอบที่มีอยู่ในบานหน้าต่างเลื่อนตลอดนอกจากบาร์เลื่อนด้านข้างสามารถประกอบด้วยส่วนหัวของคอลัมน์และแถว มุมองค์ประกอบที่มองเห็นได้เฉพาะถ้าทั้งสองฝ่ายที่ตัดกันที่มุมนั้นประกอบด้วยองค์ประกอบที่มองเห็นได้
การแปล กรุณารอสักครู่..
