Source Code Cross Referenced for SynthSplitPaneDivider.java in  » 6.0-JDK-Core » swing » javax » swing » plaf » synth » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » swing » javax.swing.plaf.synth 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 2003-2005 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025
026        package javax.swing.plaf.synth;
027
028        import java.awt.*;
029        import java.beans.*;
030        import javax.swing.*;
031        import javax.swing.plaf.basic.*;
032        import sun.swing.DefaultLookup;
033
034        /**
035         * Synth's SplitPaneDivider.
036         *
037         * @version 1.15, 05/05/07
038         * @author Scott Violet
039         */
040        class SynthSplitPaneDivider extends BasicSplitPaneDivider {
041            public SynthSplitPaneDivider(BasicSplitPaneUI ui) {
042                super (ui);
043            }
044
045            protected void setMouseOver(boolean mouseOver) {
046                if (isMouseOver() != mouseOver) {
047                    repaint();
048                }
049                super .setMouseOver(mouseOver);
050            }
051
052            public void propertyChange(PropertyChangeEvent e) {
053                super .propertyChange(e);
054                if (e.getSource() == splitPane) {
055                    if (e.getPropertyName() == JSplitPane.ORIENTATION_PROPERTY) {
056                        if (leftButton instanceof  SynthArrowButton) {
057                            ((SynthArrowButton) leftButton)
058                                    .setDirection(mapDirection(true));
059                        }
060                        if (rightButton instanceof  SynthArrowButton) {
061                            ((SynthArrowButton) rightButton)
062                                    .setDirection(mapDirection(false));
063                        }
064                    }
065                }
066            }
067
068            public void paint(Graphics g) {
069                Graphics g2 = g.create();
070
071                SynthContext context = ((SynthSplitPaneUI) splitPaneUI)
072                        .getContext(splitPane, Region.SPLIT_PANE_DIVIDER);
073                Rectangle bounds = getBounds();
074                bounds.x = bounds.y = 0;
075                SynthLookAndFeel.updateSubregion(context, g, bounds);
076                context.getPainter().paintSplitPaneDividerBackground(context,
077                        g, 0, 0, bounds.width, bounds.height,
078                        splitPane.getOrientation());
079
080                SynthPainter foreground = null;
081
082                context.getPainter().paintSplitPaneDividerForeground(context,
083                        g, 0, 0, getWidth(), getHeight(),
084                        splitPane.getOrientation());
085                context.dispose();
086
087                // super.paint(g2);
088                for (int counter = 0; counter < getComponentCount(); counter++) {
089                    Component child = getComponent(counter);
090                    Rectangle childBounds = child.getBounds();
091                    Graphics childG = g.create(childBounds.x, childBounds.y,
092                            childBounds.width, childBounds.height);
093                    child.paint(childG);
094                    childG.dispose();
095                }
096                g2.dispose();
097            }
098
099            private int mapDirection(boolean isLeft) {
100                if (isLeft) {
101                    if (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
102                        return SwingConstants.WEST;
103                    }
104                    return SwingConstants.NORTH;
105                }
106                if (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
107                    return SwingConstants.EAST;
108                }
109                return SwingConstants.SOUTH;
110            }
111
112            /**
113             * Creates and return an instance of JButton that can be used to
114             * collapse the left component in the split pane.
115             */
116            protected JButton createLeftOneTouchButton() {
117                SynthArrowButton b = new SynthArrowButton(SwingConstants.NORTH);
118                int oneTouchSize = lookupOneTouchSize();
119
120                b.setName("SplitPaneDivider.leftOneTouchButton");
121                b.setMinimumSize(new Dimension(oneTouchSize, oneTouchSize));
122                b.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
123                b.setFocusPainted(false);
124                b.setBorderPainted(false);
125                b.setRequestFocusEnabled(false);
126                b.setDirection(mapDirection(true));
127                return b;
128            }
129
130            private int lookupOneTouchSize() {
131                return DefaultLookup.getInt(splitPaneUI.getSplitPane(),
132                        splitPaneUI, "SplitPaneDivider.oneTouchButtonSize",
133                        ONE_TOUCH_SIZE);
134            }
135
136            /**
137             * Creates and return an instance of JButton that can be used to
138             * collapse the right component in the split pane.
139             */
140            protected JButton createRightOneTouchButton() {
141                SynthArrowButton b = new SynthArrowButton(SwingConstants.NORTH);
142                int oneTouchSize = lookupOneTouchSize();
143
144                b.setName("SplitPaneDivider.rightOneTouchButton");
145                b.setMinimumSize(new Dimension(oneTouchSize, oneTouchSize));
146                b.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
147                b.setFocusPainted(false);
148                b.setBorderPainted(false);
149                b.setRequestFocusEnabled(false);
150                b.setDirection(mapDirection(false));
151                return b;
152            }
153        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.