Source Code Cross Referenced for XTabPanel.java in  » XML-UI » XUI » net » xoetrope » awt » Java Source Code / Java DocumentationJava Source Code and Java Documentation

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 geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » XML UI » XUI » net.xoetrope.awt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.xoetrope.awt;
002:
003:        import java.awt.BorderLayout;
004:        import java.awt.CardLayout;
005:        import java.awt.Color;
006:        import java.awt.Component;
007:        import java.awt.FlowLayout;
008:        import java.awt.event.MouseEvent;
009:        import java.awt.event.MouseListener;
010:        import java.util.Hashtable;
011:        import net.xoetrope.builder.XuiBuilder;
012:
013:        /**
014:         * A tab panel. The methods are modelled on the JTabbedPane
015:         * <p>Copyright (c) Xoetrope Ltd., 1998-2004<br>
016:         * License:      see license.txt
017:         * $Revision: 1.10 $
018:         */
019:        public class XTabPanel extends XPanel implements  MouseListener {
020:            protected XPanel tabPane;
021:            protected XPanel contentPane;
022:            protected int selIdx;
023:            protected CardLayout cardManager;
024:
025:            public XTabPanel() {
026:                setLayout(new BorderLayout());
027:                tabPane = new XPanel();
028:
029:                FlowLayout fl = new FlowLayout();
030:                fl.setAlignment(fl.LEFT);
031:                fl.setHgap(1);
032:                fl.setVgap(0);
033:                tabPane.setLayout(fl);
034:                add(tabPane, BorderLayout.NORTH);
035:
036:                contentPane = new XPanel();
037:                contentPane.setLayout(cardManager = new CardLayout());
038:                add(contentPane, BorderLayout.CENTER);
039:
040:                selIdx = 0;
041:            }
042:
043:            /**
044:             * Add a new tab.
045:             * The add method could not be overloaded so this method adds does the
046:             * equivalent.
047:             * @param name the name/caption of the tab component
048:             * @param panel the content
049:             */
050:            public Component add(Component comp) {
051:                String title = null;
052:                try {
053:                    Hashtable attribs = XuiBuilder.getCurrentAttributes();
054:                    title = (String) attribs.get("title");
055:                } catch (Exception ex) {
056:                }
057:                addTab(title, comp);
058:                return comp;
059:            }
060:
061:            /**
062:             * Add a new tab.
063:             * The add method could not be overloaded so this method adds does the
064:             * equivalent.
065:             * @param name the name/caption of the tab component
066:             * @param panel the content
067:             */
068:            public void addTab(String name, Component panel) {
069:                XTab tab = new XTab(name);
070:                tabPane.add(tab);
071:                contentPane.add(panel, name);
072:                tab.addMouseListener(this );
073:            }
074:
075:            public Component getComponentAt(int index) {
076:                return contentPane.getComponent(index);
077:            }
078:
079:            public Color getBackgroundAt(int index) {
080:                return tabPane.getComponent(index).getBackground();
081:            }
082:
083:            public Color getForegroundAt(int index) {
084:                return tabPane.getComponent(index).getForeground();
085:            }
086:
087:            public int getTabCount() {
088:                return tabPane.getComponentCount();
089:            }
090:
091:            public int getSelectedIndex() {
092:                return selIdx;
093:            }
094:
095:            public String getTitleAt(int index) {
096:                return ((XTab) tabPane.getComponent(index)).getText();
097:            }
098:
099:            public void setBackgroundAt(int index, Color clr) {
100:                ((XTab) tabPane.getComponent(index)).setBackground(clr);
101:            }
102:
103:            public void setForegroundAt(int index, Color clr) {
104:                ((XTab) tabPane.getComponent(index)).setForeground(clr);
105:            }
106:
107:            public void setSelectedIndex(int index) {
108:                if (index != selIdx) {
109:                    XTab oldSelection = (XTab) tabPane.getComponent(selIdx);
110:                    oldSelection.setSelected(false);
111:                    oldSelection.repaint();
112:                }
113:
114:                selIdx = index;
115:                XTab newSelection = (XTab) tabPane.getComponent(selIdx);
116:                newSelection.setSelected(true);
117:                newSelection.repaint();
118:                cardManager.show(contentPane, ((XTab) tabPane
119:                        .getComponent(selIdx)).getText());
120:                repaint();
121:            }
122:
123:            public void setTitleAt(int index, String str) {
124:                ((XTab) tabPane.getComponent(index)).setText(str);
125:            }
126:
127:            /**
128:             * Toggle the frame display. The frame is drawn around the content pane
129:             * @param val 0 for no frame, 1 for a bevel, 2 for a flat frame
130:             */
131:            public void setDrawFrame(int value) {
132:                int gap = Math.min(value, 2);
133:                cardManager.setHgap(gap);
134:                cardManager.setVgap(gap);
135:                contentPane.setDrawFrame(value);
136:            }
137:
138:            //-Mouse listener methods-----------------------------------------------------
139:            /**
140:             * Invoked when the mouse button has been clicked (pressed
141:             * and released) on a component.
142:             */
143:            public void mouseClicked(MouseEvent e) {
144:            }
145:
146:            /**
147:             * Invoked when a mouse button has been pressed on a component.
148:             */
149:            public void mousePressed(MouseEvent e) {
150:                XTab oldSelection = null;
151:                XTab comp = (XTab) e.getSource();
152:
153:                int numComponents = tabPane.getComponentCount();
154:                for (int i = 0; i < numComponents; i++) {
155:                    XTab tabObj = (XTab) tabPane.getComponent(i);
156:                    if (tabObj.selected) {
157:                        oldSelection = (XTab) tabPane.getComponent(i);
158:                        oldSelection.setSelected(false);
159:                        oldSelection.repaint();
160:                    } else if (comp == tabObj)
161:                        selIdx = i;
162:                }
163:
164:                cardManager.show(contentPane, comp.getText());
165:                comp.setSelected(true);
166:                comp.repaint();
167:            }
168:
169:            /**
170:             * Invoked when a mouse button has been released on a component.
171:             */
172:            public void mouseReleased(MouseEvent e) {
173:            }
174:
175:            /**
176:             * Invoked when the mouse enters a component.
177:             */
178:            public void mouseEntered(MouseEvent e) {
179:            }
180:
181:            /**
182:             * Invoked when the mouse exits a component.
183:             */
184:            public void mouseExited(MouseEvent e) {
185:            }
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.