Source Code Cross Referenced for Application_027.java in  » IDE-Netbeans » jemmy » org » netbeans » jemmy » testing » 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 » IDE Netbeans » jemmy » org.netbeans.jemmy.testing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.netbeans.jemmy.testing;
002:
003:        import java.awt.*;
004:        import java.util.*;
005:
006:        import java.awt.event.*;
007:
008:        import javax.swing.*;
009:        import javax.swing.border.*;
010:        import javax.swing.event.*;
011:        import javax.swing.tree.*;
012:        import javax.swing.table.*;
013:
014:        public class Application_027 extends TestFrame {
015:
016:            String[] tableColumns;
017:
018:            public Application_027() {
019:                super ("Application_027");
020:
021:                JTabbedPane tp = new JTabbedPane();
022:
023:                //////////////////////////////////////////////////////////////////////
024:                //table
025:                //////////////////////////////////////////////////////////////////////
026:                tableColumns = new String[5];
027:                String[][] tableItems = new String[5][5];
028:                for (int i = 0; i < tableColumns.length; i++) {
029:                    tableColumns[i] = Integer.toString(i);
030:                    for (int j = 0; j < tableItems[i].length; j++) {
031:                        tableItems[j][i] = Integer.toString(i)
032:                                + Integer.toString(j);
033:                    }
034:                }
035:                JTable tbl = new JTable(tableItems, tableColumns);
036:                tbl.setCellSelectionEnabled(true);
037:                tbl.setRowHeight(tbl.getRowHeight() * 2);
038:
039:                TableCellRenderer renderer = new TableCellRenderer() {
040:                    public Component getTableCellRendererComponent(
041:                            JTable table, Object value, boolean isSelected,
042:                            boolean cellHasFocus, int row, int column) {
043:                        JPanel res = new JPanel();
044:                        if (isSelected) {
045:                            res.setBorder(new BevelBorder(BevelBorder.LOWERED));
046:                            res.add(new JLabel("!" + value.toString() + "!"));
047:                        } else {
048:                            res.add(new JLabel(value.toString()));
049:                        }
050:                        return (res);
051:                    }
052:                };
053:
054:                TableCellEditor editor = new TableDualComboEditor();
055:
056:                for (int i = 0; i < tableColumns.length; i++) {
057:                    tbl.getColumnModel().getColumn(i).setCellRenderer(renderer);
058:                    tbl.getColumnModel().getColumn(i).setCellEditor(editor);
059:                }
060:
061:                tp.add("Table Page", new JScrollPane(tbl));
062:
063:                //////////////////////////////////////////////////////////////////////
064:                //tree
065:                //////////////////////////////////////////////////////////////////////
066:                DefaultMutableTreeNode[][] subnodes = new DefaultMutableTreeNode[5][5];
067:                DefaultMutableTreeNode[] nodes = new DefaultMutableTreeNode[5];
068:                DefaultMutableTreeNode root = new DefaultMutableTreeNode();
069:                root.setUserObject("00");
070:                for (int i = 0; i < nodes.length; i++) {
071:                    nodes[i] = new DefaultMutableTreeNode();
072:                    nodes[i].setUserObject(Integer.toString(i) + "0");
073:                    for (int j = 0; j < subnodes[i].length; j++) {
074:                        subnodes[i][j] = new DefaultMutableTreeNode();
075:                        subnodes[i][j].setUserObject(Integer.toString(i)
076:                                + Integer.toString(j));
077:                        nodes[i].insert(subnodes[i][j], j);
078:                    }
079:                    root.insert(nodes[i], i);
080:                }
081:                JTree tr = new JTree(root);
082:
083:                TreeCellRenderer treeRenderer = new TreeCellRenderer() {
084:                    public Component getTreeCellRendererComponent(JTree tree,
085:                            Object value, boolean isSelected,
086:                            boolean isExpanded, boolean isLeaf, int row,
087:                            boolean cellHasFocus) {
088:                        JPanel res = new JPanel();
089:                        if (isSelected) {
090:                            res.setBorder(new BevelBorder(BevelBorder.LOWERED));
091:                            res.add(new JLabel("!" + value.toString() + "!"));
092:                        } else {
093:                            res.add(new JLabel(value.toString()));
094:                        }
095:                        return (res);
096:                    }
097:                };
098:
099:                tr.setCellRenderer(treeRenderer);
100:                tr.setCellEditor(new TreeDualComboEditor());
101:
102:                tr.setEditable(true);
103:                tp.add("Tree Page", new JScrollPane(tr));
104:
105:                //////////////////////////////////////////////////////////////////////
106:                //list
107:                //////////////////////////////////////////////////////////////////////
108:                String[] listItems = new String[5];
109:                for (int i = 0; i < listItems.length; i++) {
110:                    listItems[i] = Integer.toString(i);
111:                }
112:                JList list = new JList(listItems);
113:                list.setCellRenderer(new ListCellRenderer() {
114:                    public Component getListCellRendererComponent(JList list,
115:                            Object value, int index, boolean isSelected,
116:                            boolean cellHasFocus) {
117:                        JPanel res = new JPanel();
118:                        if (isSelected) {
119:                            res.setBorder(new BevelBorder(BevelBorder.LOWERED));
120:                            res.add(new JLabel("!" + value.toString() + "!"));
121:                        } else {
122:                            res.add(new JLabel(value.toString()));
123:                        }
124:                        return (res);
125:                    }
126:                });
127:
128:                tp.add("List Page", new JScrollPane(list));
129:
130:                getContentPane().add(tp);
131:
132:                setSize(600, 400);
133:            }
134:
135:            public static void main(String[] argv) {
136:                (new Application_027()).show();
137:            }
138:
139:            class TableDualComboEditor implements  TableCellEditor {
140:                JComboBox fCombo, sCombo;
141:                JPanel res;
142:                int row, column;
143:                JTable tbl;
144:                Vector lists;
145:
146:                public TableDualComboEditor() {
147:                    res = new JPanel();
148:                    fCombo = new JComboBox(tableColumns);
149:                    sCombo = new JComboBox(tableColumns);
150:                    res.add(fCombo);
151:                    res.add(sCombo);
152:                    lists = new Vector();
153:                }
154:
155:                public Component getTableCellEditorComponent(JTable table,
156:                        Object value, boolean isSelected, int row, int column) {
157:                    this .row = row;
158:                    this .column = column;
159:                    this .tbl = table;
160:                    fCombo.setSelectedIndex(new Integer(value.toString()
161:                            .substring(0, 1)).intValue());
162:                    sCombo.setSelectedIndex(new Integer(value.toString()
163:                            .substring(1)).intValue());
164:                    return (res);
165:                }
166:
167:                public void addCellEditorListener(CellEditorListener l) {
168:                    lists.add(l);
169:                };
170:
171:                public void cancelCellEditing() {
172:                    res.setVisible(false);
173:                    for (int i = 0; i < lists.size(); i++) {
174:                        ((CellEditorListener) lists.get(i))
175:                                .editingCanceled(new ChangeEvent(tbl));
176:                    }
177:                }
178:
179:                public Object getCellEditorValue() {
180:                    return (Integer.toString(fCombo.getSelectedIndex()) + Integer
181:                            .toString(sCombo.getSelectedIndex()));
182:                }
183:
184:                public boolean isCellEditable(EventObject anEvent) {
185:                    return (anEvent instanceof  MouseEvent && ((MouseEvent) anEvent)
186:                            .getClickCount() > 1);
187:                }
188:
189:                public void removeCellEditorListener(CellEditorListener l) {
190:                    lists.remove(l);
191:                }
192:
193:                public boolean shouldSelectCell(EventObject anEvent) {
194:                    return (true);
195:                }
196:
197:                public boolean stopCellEditing() {
198:                    tbl.getModel()
199:                            .setValueAt(getCellEditorValue(), row, column);
200:                    for (int i = 0; i < lists.size(); i++) {
201:                        ((CellEditorListener) lists.get(i))
202:                                .editingStopped(new ChangeEvent(tbl));
203:                    }
204:                    return (true);
205:                }
206:            }
207:
208:            class TreeDualComboEditor implements  TreeCellEditor {
209:                JComboBox fCombo, sCombo;
210:                JPanel res;
211:                TreePath path;
212:                JTree tree;
213:                Vector lists;
214:
215:                public TreeDualComboEditor() {
216:                    res = new JPanel();
217:                    fCombo = new JComboBox(tableColumns);
218:                    fCombo.setPopupVisible(false);
219:                    sCombo = new JComboBox(tableColumns);
220:                    sCombo.setPopupVisible(false);
221:                    res.add(fCombo);
222:                    res.add(sCombo);
223:                    lists = new Vector();
224:                }
225:
226:                public Component getTreeCellEditorComponent(JTree tree,
227:                        Object value, boolean isSelected, boolean isExpanded,
228:                        boolean isLeaf, int row) {
229:                    this .path = tree.getPathForRow(row);
230:                    this .tree = tree;
231:                    fCombo.setSelectedIndex(new Integer(value.toString()
232:                            .substring(0, 1)).intValue());
233:                    sCombo.setSelectedIndex(new Integer(value.toString()
234:                            .substring(1)).intValue());
235:                    res.setVisible(true);
236:                    return (res);
237:                }
238:
239:                public void addCellEditorListener(CellEditorListener l) {
240:                    lists.add(l);
241:                };
242:
243:                public void cancelCellEditing() {
244:                    res.setVisible(false);
245:                    ((DefaultMutableTreeNode) path.getLastPathComponent())
246:                            .setUserObject(getCellEditorValue());
247:                    for (int i = 0; i < lists.size(); i++) {
248:                        ((CellEditorListener) lists.get(i))
249:                                .editingCanceled(new ChangeEvent(tree));
250:                    }
251:                }
252:
253:                public Object getCellEditorValue() {
254:                    return (Integer.toString(fCombo.getSelectedIndex()) + Integer
255:                            .toString(sCombo.getSelectedIndex()));
256:                }
257:
258:                public boolean isCellEditable(EventObject anEvent) {
259:                    return (anEvent instanceof  MouseEvent && ((MouseEvent) anEvent)
260:                            .getClickCount() > 1);
261:                }
262:
263:                public void removeCellEditorListener(CellEditorListener l) {
264:                    lists.remove(l);
265:                }
266:
267:                public boolean shouldSelectCell(EventObject anEvent) {
268:                    return (true);
269:                }
270:
271:                public boolean stopCellEditing() {
272:                    ((DefaultMutableTreeNode) path.getLastPathComponent())
273:                            .setUserObject(getCellEditorValue());
274:                    for (int i = 0; i < lists.size(); i++) {
275:                        ((CellEditorListener) lists.get(i))
276:                                .editingStopped(new ChangeEvent(tree));
277:                    }
278:                    return (true);
279:                }
280:            }
281:
282:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.