diff options
author | kcr <kcr@28c7f869-5b4e-e670-f602-82bfaf57f300> | 2006-03-06 22:33:14 +0000 |
---|---|---|
committer | kcr <kcr@28c7f869-5b4e-e670-f602-82bfaf57f300> | 2006-03-06 22:33:14 +0000 |
commit | e33696b60429fb58aa74fbf989d9b4a76488d4c2 (patch) | |
tree | 5d2c79a8f50ebe35c9f3dd1a7178cb8ff2733694 /src/classes/org/jdesktop | |
parent | c677ffd9129f3fa0cee7881220a45a2918db0559 (diff) |
Display output in a JTextArea component, rather than printing to System.out.
Diffstat (limited to 'src/classes/org/jdesktop')
4 files changed, 238 insertions, 54 deletions
diff --git a/src/classes/org/jdesktop/j3d/examples/package_info/PackageInfo.form b/src/classes/org/jdesktop/j3d/examples/package_info/PackageInfo.form new file mode 100644 index 0000000..a82c39c --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/package_info/PackageInfo.form @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.0" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="3"/> + <Property name="title" type="java.lang.String" value="Package Info"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[400, 400]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="myTextArea"> + <Properties> + <Property name="columns" type="int" value="20"/> + <Property name="editable" type="boolean" value="false"/> + <Property name="rows" type="int" value="5"/> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/package_info/PackageInfo.java b/src/classes/org/jdesktop/j3d/examples/package_info/PackageInfo.java index 2cc6cad..90c6efa 100644 --- a/src/classes/org/jdesktop/j3d/examples/package_info/PackageInfo.java +++ b/src/classes/org/jdesktop/j3d/examples/package_info/PackageInfo.java @@ -44,52 +44,96 @@ package org.jdesktop.j3d.examples.package_info; -public class PackageInfo { - public PackageInfo() { - ClassLoader classLoader = getClass().getClassLoader(); +import javax.swing.JTextArea; - pkgInfo(classLoader, "javax.vecmath", "Point3d"); - pkgInfo(classLoader, "javax.media.j3d", "SceneGraphObject"); - pkgInfo(classLoader, "com.sun.j3d.utils.universe", "SimpleUniverse"); - //pkgInfo(classLoader, "com.sun.j3d.loaders.vrml97", "VrmlLoader"); - } +public class PackageInfo extends javax.swing.JFrame { + + private void pkgInfo(JTextArea textArea, + ClassLoader classLoader, + String pkgName, + String className) { + + try { + classLoader.loadClass(pkgName + "." + className); + + Package p = Package.getPackage(pkgName); + if (p == null) { + textArea.append("WARNING: Package.getPackage(" + + pkgName + + ") is null\n"); + } else { + textArea.append(p.toString() + "\n"); + textArea.append("Specification Title = " + + p.getSpecificationTitle() + "\n"); + textArea.append("Specification Vendor = " + + p.getSpecificationVendor() + "\n"); + textArea.append("Specification Version = " + + p.getSpecificationVersion() + "\n"); - static void pkgInfo(ClassLoader classLoader, - String pkgName, - String className) { + textArea.append("Implementation Vendor = " + + p.getImplementationVendor() + "\n"); + textArea.append("Implementation Version = " + + p.getImplementationVersion() + "\n"); + } + } catch (ClassNotFoundException e) { + textArea.append("Unable to load " + pkgName + "\n"); + } - try { - classLoader.loadClass(pkgName + "." + className); + textArea.append("\n"); + } - Package p = Package.getPackage(pkgName); - if (p == null) { - System.out.println("WARNING: Package.getPackage(" + - pkgName + - ") is null"); - } - else { - System.out.println(p); - System.out.println("Specification Title = " + - p.getSpecificationTitle()); - System.out.println("Specification Vendor = " + - p.getSpecificationVendor()); - System.out.println("Specification Version = " + - p.getSpecificationVersion()); + /** + * Creates new form PackageInfo + */ + public PackageInfo() { + initComponents(); - System.out.println("Implementation Vendor = " + - p.getImplementationVendor()); - System.out.println("Implementation Version = " + - p.getImplementationVersion()); - } - } - catch (ClassNotFoundException e) { - System.out.println("Unable to load " + pkgName); - } + ClassLoader classLoader = getClass().getClassLoader(); - System.out.println(); + pkgInfo(myTextArea, classLoader, "javax.vecmath", "Point3d"); + pkgInfo(myTextArea, classLoader, "javax.media.j3d", "SceneGraphObject"); + pkgInfo(myTextArea, classLoader, "com.sun.j3d.utils.universe", "SimpleUniverse"); } - public static void main(String[] args) { - new PackageInfo(); + // ---------------------------------------------------------------- + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents + private void initComponents() { + jScrollPane1 = new javax.swing.JScrollPane(); + myTextArea = new javax.swing.JTextArea(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("Package Info"); + jScrollPane1.setPreferredSize(new java.awt.Dimension(400, 400)); + myTextArea.setColumns(20); + myTextArea.setEditable(false); + myTextArea.setRows(5); + jScrollPane1.setViewportView(myTextArea); + + getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new PackageInfo().setVisible(true); + } + }); } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTextArea myTextArea; + // End of variables declaration//GEN-END:variables + } diff --git a/src/classes/org/jdesktop/j3d/examples/package_info/QueryProperties.form b/src/classes/org/jdesktop/j3d/examples/package_info/QueryProperties.form new file mode 100644 index 0000000..daef961 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/package_info/QueryProperties.form @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.0" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="3"/> + <Property name="title" type="java.lang.String" value="QueryProperties"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[400, 500]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="myTextArea"> + <Properties> + <Property name="columns" type="int" value="20"/> + <Property name="editable" type="boolean" value="false"/> + <Property name="rows" type="int" value="5"/> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/package_info/QueryProperties.java b/src/classes/org/jdesktop/j3d/examples/package_info/QueryProperties.java index fb34965..4febcd6 100644 --- a/src/classes/org/jdesktop/j3d/examples/package_info/QueryProperties.java +++ b/src/classes/org/jdesktop/j3d/examples/package_info/QueryProperties.java @@ -44,14 +44,22 @@ package org.jdesktop.j3d.examples.package_info; -import java.util.*; -import javax.media.j3d.*; import java.awt.GraphicsEnvironment; import java.awt.GraphicsConfiguration; -import com.sun.j3d.utils.universe.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import javax.media.j3d.Canvas3D; +import javax.media.j3d.GraphicsConfigTemplate3D; +import javax.media.j3d.VirtualUniverse; +import javax.swing.JTextArea; -public class QueryProperties { - public static void printProps(Map map, String[] propList) { +public class QueryProperties extends javax.swing.JFrame { + + public static void printProps(JTextArea textArea, Map map, String[] propList) { // Create an alphabetical list of keys List keyList = new ArrayList(map.keySet()); Collections.sort(keyList); @@ -69,7 +77,7 @@ public class QueryProperties { if (idxWild < 0) { key = propList[i]; if (!hs.contains(key)) { - System.out.println(key + " = " + map.get(key)); + textArea.append(key + " = " + map.get(key) + "\n"); hs.add(key); } } @@ -79,14 +87,14 @@ public class QueryProperties { while (it.hasNext()) { key = (String)it.next(); if (key.startsWith(pattern) && !hs.contains(key)) { - System.out.println(key + " = " + map.get(key)); + textArea.append(key + " = " + map.get(key) + "\n"); hs.add(key); } } } else { - System.out.println(propList[i] + - " = ERROR: KEY WITH EMBEDDED WILD CARD IGNORED"); + textArea.append(propList[i] + + " = ERROR: KEY WITH EMBEDDED WILD CARD IGNORED\n"); } } @@ -95,13 +103,16 @@ public class QueryProperties { while (it.hasNext()) { key = (String)it.next(); if (!hs.contains(key)) { - System.out.println(key + " = " + map.get(key)); + textArea.append(key + " = " + map.get(key) + "\n"); } } } - public static void main(String[] args) { + /** Creates new form QueryProperties */ + public QueryProperties() { + initComponents(); + VirtualUniverse vu = new VirtualUniverse(); Map vuMap = vu.getProperties(); final String[] vuPropList = { @@ -113,8 +124,8 @@ public class QueryProperties { // Just print all other properties in alphabetical order }; - printProps(vuMap, vuPropList); - System.out.println(); + printProps(myTextArea, vuMap, vuPropList); + myTextArea.append("\n"); GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D(); @@ -143,8 +154,48 @@ public class QueryProperties { // Just print all other properties in alphabetical order }; - printProps(c3dMap, c3dPropList); + printProps(myTextArea, c3dMap, c3dPropList); + } + + // ---------------------------------------------------------------- + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents + private void initComponents() { + jScrollPane1 = new javax.swing.JScrollPane(); + myTextArea = new javax.swing.JTextArea(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("QueryProperties"); + jScrollPane1.setPreferredSize(new java.awt.Dimension(400, 500)); + myTextArea.setColumns(20); + myTextArea.setEditable(false); + myTextArea.setRows(5); + jScrollPane1.setViewportView(myTextArea); + + getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER); - System.exit(0); + pack(); + }// </editor-fold>//GEN-END:initComponents + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new QueryProperties().setVisible(true); + } + }); } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTextArea myTextArea; + // End of variables declaration//GEN-END:variables + } |