KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > form > fakepeer > FakeScrollbarPeer


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20
21 package org.netbeans.modules.form.fakepeer;
22
23 import java.awt.*;
24
25 /**
26  *
27  * @author Tran Duc Trung
28  */

29 class FakeScrollbarPeer extends FakeComponentPeer
30 {
31     FakeScrollbarPeer(Scrollbar target) {
32         super(target);
33     }
34
35     Component createDelegate() {
36         return new Delegate();
37     }
38
39     public void setValues(int value, int visible, int minimum, int maximum) {}
40     public void setLineIncrement(int l) {}
41     public void setPageIncrement(int l) {}
42
43     //
44
//
45
//
46

47     private class Delegate extends Component
48     {
49         Delegate() {
50             this.setBackground(SystemColor.scrollbar);
51         }
52         
53         public void paint(Graphics g) {
54             Scrollbar target = (Scrollbar) _target;
55             Dimension sz = target.getSize();
56             int scrollRange = target.getMaximum() - target.getMinimum();
57             int scrollValue = target.getValue() - target.getMinimum();
58             int thumbAmount = target.getVisibleAmount();
59
60             g.setColor(target.getBackground());
61
62             FakePeerUtils.drawScrollbar(g,
63                                         0, 0, sz.width, sz.height,
64                                         target.getOrientation(),
65                                         target.isEnabled(),
66                                         true,
67                                         scrollValue,
68                                         thumbAmount,
69                                         scrollRange);
70         }
71
72         public Dimension getMinimumSize() {
73             Scrollbar target =(Scrollbar) _target;
74             return target.getOrientation() == Scrollbar.HORIZONTAL ?
75                 new Dimension(3 * FakePeerUtils.SCROLL_W, FakePeerUtils.SCROLL_H) :
76                 new Dimension(FakePeerUtils.SCROLL_W, 3 * FakePeerUtils.SCROLL_H);
77         }
78     }
79 }
80
Popular Tags