1 7 package com.sun.java.swing.plaf.motif; 8 9 import javax.swing.*; 10 import javax.swing.event.*; 11 import javax.swing.plaf.*; 12 import javax.swing.border.*; 13 import javax.swing.plaf.basic.BasicScrollBarUI ; 14 15 import java.awt.Dimension ; 16 import java.awt.Insets ; 17 import java.awt.Rectangle ; 18 import java.awt.Graphics ; 19 import java.awt.Color ; 20 21 22 36 public class MotifScrollBarUI extends BasicScrollBarUI 37 { 38 39 public static ComponentUI createUI(JComponent c) { 40 return new MotifScrollBarUI(); 41 } 42 43 public Dimension getPreferredSize(JComponent c) { 44 Insets insets = c.getInsets(); 45 int dx = insets.left + insets.right; 46 int dy = insets.top + insets.bottom; 47 return (scrollbar.getOrientation() == JScrollBar.VERTICAL) 48 ? new Dimension (dx + 11, dy + 33) 49 : new Dimension (dx + 33, dy + 11); 50 } 51 52 protected JButton createDecreaseButton(int orientation) { 53 return new MotifScrollBarButton(orientation); 54 } 55 56 protected JButton createIncreaseButton(int orientation) { 57 return new MotifScrollBarButton(orientation); 58 } 59 60 61 public void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) { 62 g.setColor(trackColor); 63 g.fillRect(trackBounds.x, trackBounds.y, trackBounds.width, trackBounds.height); 64 } 65 66 67 public void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) 68 { 69 70 if(thumbBounds.isEmpty() || !scrollbar.isEnabled()) { 71 return; 72 } 73 74 int w = thumbBounds.width; 75 int h = thumbBounds.height; 76 77 g.translate(thumbBounds.x, thumbBounds.y); 78 g.setColor(thumbColor); 79 g.fillRect(0, 0, w-1, h-1); 80 81 g.setColor(thumbHighlightColor); 82 g.drawLine(0, 0, 0, h-1); 83 g.drawLine(1, 0, w-1, 0); 84 85 g.setColor(thumbLightShadowColor); 86 g.drawLine(1, h-1, w-1, h-1); 87 g.drawLine(w-1, 1, w-1, h-2); 88 89 g.translate(-thumbBounds.x, -thumbBounds.y); 90 } 91 } 92 | Popular Tags |