Source Code Cross Referenced for AncientSwingTeam.java in  » Swing-Library » swingx » org » jdesktop » test » 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 » Swing Library » swingx » org.jdesktop.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.jdesktop.test;
002:
003:        import java.awt.Color;
004:
005:        import javax.swing.table.AbstractTableModel;
006:
007:        /**
008:         * Standard Table with class-Infos. Taken from some old
009:         * SwingSet... 
010:         * Can remove/add rows.
011:         */
012:        public class AncientSwingTeam extends AbstractTableModel {
013:
014:            protected final String[] names = { "First Name", "Last Name",
015:                    "Favorite Color", "No.", "Vegetarian" };
016:            NamedColor aqua = new NamedColor(new Color(127, 255, 212), "Aqua");
017:            NamedColor beige = new NamedColor(new Color(245, 245, 220),
018:                    ("Beige"));
019:            NamedColor black = new NamedColor(Color.black, "Black");
020:            NamedColor blue = new NamedColor(new Color(0, 0, 222), "Blue");
021:            NamedColor eblue = new NamedColor(Color.blue, "Electric Blue");
022:            NamedColor jfcblue = new NamedColor(new Color(204, 204, 255),
023:                    "JFC Primary");
024:            NamedColor jfcblue2 = new NamedColor(new Color(153, 153, 204),
025:                    "JFC SEcondary");
026:            NamedColor cybergreen = new NamedColor(Color.green.darker()
027:                    .brighter(), "Cyber Green");
028:            NamedColor darkgreen = new NamedColor(new Color(0, 100, 75),
029:                    "darkgreen");
030:            NamedColor forestgreen = new NamedColor(Color.green.darker(),
031:                    "Forest Green");
032:            NamedColor gray = new NamedColor(Color.gray, "Gray");
033:            NamedColor green = new NamedColor(Color.green, "Green");
034:            NamedColor orange = new NamedColor(new Color(255, 165, 0), "Orange");
035:            NamedColor purple = new NamedColor(new Color(160, 32, 240),
036:                    "Purple");
037:            NamedColor red = new NamedColor(Color.red, "Red");
038:            NamedColor rustred = new NamedColor(Color.red.darker(), "Rust Red");
039:            NamedColor sunpurple = new NamedColor(new Color(100, 100, 255),
040:                    "Sun Purple");
041:            NamedColor suspectpink = new NamedColor(new Color(255, 105, 180),
042:                    "Suspect Pink");
043:            NamedColor turquoise = new NamedColor(new Color(0, 255, 255),
044:                    "Turquoise");
045:            NamedColor violet = new NamedColor(new Color(238, 130, 238),
046:                    "Violet");
047:            NamedColor yellow = new NamedColor(Color.yellow, "Yellow");
048:
049:            protected final Object[][] data = {
050:                    { "Mark", "Andrews", red, new Integer(2), new Boolean(true) },
051:                    { "Tom", "Ball", blue, new Integer(99), new Boolean(false) },
052:                    { "Alan", "Chung", green, new Integer(838),
053:                            new Boolean(false) },
054:                    { "Jeff", "Dinkins", turquoise, new Integer(8),
055:                            new Boolean(true) },
056:                    { "Amy", "Fowler", yellow, new Integer(3),
057:                            new Boolean(false) },
058:                    { "Brian", "Gerhold", green, new Integer(0),
059:                            new Boolean(false) },
060:                    { "James", "Gosling", suspectpink, new Integer(21),
061:                            new Boolean(false) },
062:                    { "David", "Karlton", red, new Integer(1),
063:                            new Boolean(false) },
064:                    { "Dave", "Kloba", yellow, new Integer(14),
065:                            new Boolean(false) },
066:                    { "Peter", "Korn", purple, new Integer(12),
067:                            new Boolean(false) },
068:                    { "Phil", "Milne", purple, new Integer(3),
069:                            new Boolean(false) },
070:                    { "Dave", "Moore", green, new Integer(88),
071:                            new Boolean(false) },
072:                    { "Hans", "Muller", rustred, new Integer(5),
073:                            new Boolean(false) },
074:
075:                    { "Rick", "Levenson", blue, new Integer(2),
076:                            new Boolean(false) },
077:                    { "Tim", "Prinzing", blue, new Integer(22),
078:                            new Boolean(false) },
079:                    { "Chester", "Rose", black, new Integer(0),
080:                            new Boolean(false) },
081:                    { "Ray", "Ryan", gray, new Integer(77), new Boolean(false) },
082:                    { "Georges", "Saab", red, new Integer(4),
083:                            new Boolean(false) },
084:                    { "Willie", "Walker", jfcblue, new Integer(4),
085:                            new Boolean(false) },
086:
087:                    { "Kathy", "Walrath", blue, new Integer(8),
088:                            new Boolean(false) },
089:                    { "Arnaud", "Weber", green, new Integer(44),
090:                            new Boolean(false) } };
091:
092:            protected int rowCount = data.length;
093:
094:            public AncientSwingTeam() {
095:
096:            }
097:
098:            public AncientSwingTeam(int count) {
099:                rowCount = count;
100:            }
101:
102:            public int getColumnCount() {
103:                return names.length;
104:            }
105:
106:            public int getRowCount() {
107:                return rowCount;
108:            }
109:
110:            /** reuses values internally */
111:            public Object getValueAt(int row, int col) {
112:                // following shows only every second value
113:                // if ((row + col) % 2 == 0) return null;
114:                return data[row % data.length][col];
115:            }
116:
117:            public void setValueAt(Object value, int row, int col) {
118:                data[row % data.length][col] = value;
119:                fireTableCellUpdated(row, col);
120:            }
121:
122:            // The default implementations of these methods in
123:            // AbstractTableModel would work, but we can refine them.
124:            public String getColumnName(int column) {
125:                return names[column];
126:            }
127:
128:            /** returns class of column by asking class of value in first row. */
129:            public Class getColumnClass(int c) {
130:                Object value = null;
131:                if (getRowCount() > 0) {
132:                    value = getValueAt(0, c);
133:                }
134:                if (value == null) {
135:                    return Object.class;
136:                }
137:                return value.getClass();
138:            }
139:
140:            /** everything is editable. */
141:            public boolean isCellEditable(int row, int col) {
142:                return true;
143:            }
144:
145:            /**
146:             * insert length rows at rowIndex. PRE: rowIndex <= getRowCount()
147:             */
148:            public void insertRows(int rowIndex, int length) {
149:                rowCount += length;
150:                fireTableRowsInserted(rowIndex, rowIndex + length - 1);
151:            }
152:
153:            /**
154:             * remove rows. NOTE: not tested
155:             */
156:            public void removeRows(int rowIndex, int length) {
157:                rowCount -= length;
158:                if (rowCount < 0) {
159:                    length -= rowCount;
160:                    rowCount = 0;
161:                }
162:                fireTableRowsDeleted(rowIndex, rowIndex + length - 1);
163:            }
164:
165:            public static class NamedColor extends Color {
166:                String name;
167:
168:                public NamedColor(Color color, String name) {
169:                    super (color.getRGB());
170:                    this .name = name;
171:                }
172:
173:                public Color getTextColor() {
174:                    int r = getRed();
175:                    int g = getGreen();
176:                    int b = getBlue();
177:                    if (r > 240 || g > 240) {
178:                        return Color.black;
179:                    } else {
180:                        return Color.white;
181:                    }
182:                }
183:
184:                public String toString() {
185:                    return name;
186:                }
187:
188:            }
189:        } // end class SwingTeam
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.