1.1 --- a/samples/componentinjection/anagram-modular/nbproject/project.xml Sat Jun 14 10:06:50 2008 +0200
1.2 +++ b/samples/componentinjection/anagram-modular/nbproject/project.xml Sat Jun 14 10:06:53 2008 +0200
1.3 @@ -28,6 +28,12 @@
1.4 <encoding>UTF-8</encoding>
1.5 </source-folder>
1.6 <source-folder>
1.7 + <label>src-gui</label>
1.8 + <type>java</type>
1.9 + <location>src-gui</location>
1.10 + <encoding>UTF-8</encoding>
1.11 + </source-folder>
1.12 + <source-folder>
1.13 <label>Anagram Modular</label>
1.14 <location>.</location>
1.15 <encoding>UTF-8</encoding>
1.16 @@ -78,6 +84,10 @@
1.17 <label>src-scrambler-simple</label>
1.18 <location>src-scrambler-simple</location>
1.19 </source-folder>
1.20 + <source-folder style="packages">
1.21 + <label>src-gui</label>
1.22 + <location>src-gui</location>
1.23 + </source-folder>
1.24 <source-file>
1.25 <location>build.xml</location>
1.26 </source-file>
1.27 @@ -111,6 +121,12 @@
1.28 <source-level>1.5</source-level>
1.29 </compilation-unit>
1.30 <compilation-unit>
1.31 + <package-root>src-gui</package-root>
1.32 + <classpath mode="compile">src-api</classpath>
1.33 + <built-to>build/gui/classes</built-to>
1.34 + <source-level>1.5</source-level>
1.35 + </compilation-unit>
1.36 + <compilation-unit>
1.37 <package-root>src-test</package-root>
1.38 <classpath mode="compile">src-new-api:../libs/dist/junit-4.4.jar</classpath>
1.39 <source-level>1.5</source-level>
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/samples/componentinjection/anagram-modular/src-gui/org/apidesign/anagram/gui/About.form Sat Jun 14 10:06:53 2008 +0200
2.3 @@ -0,0 +1,76 @@
2.4 +<?xml version="1.0" encoding="UTF-8" ?>
2.5 +
2.6 +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
2.7 + <Properties>
2.8 + <Property name="defaultCloseOperation" type="int" value="2"/>
2.9 + <Property name="title" type="java.lang.String" value="About Anagrams"/>
2.10 + </Properties>
2.11 + <SyntheticProperties>
2.12 + <SyntheticProperty name="formSize" 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,0,-25,0,0,1,53"/>
2.13 + <SyntheticProperty name="formSizePolicy" type="int" value="0"/>
2.14 + <SyntheticProperty name="generateSize" type="boolean" value="true"/>
2.15 + <SyntheticProperty name="generateCenter" type="boolean" value="true"/>
2.16 + </SyntheticProperties>
2.17 + <Events>
2.18 + <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="exitForm"/>
2.19 + </Events>
2.20 + <AuxValues>
2.21 + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
2.22 + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
2.23 + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
2.24 + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
2.25 + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
2.26 + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
2.27 + </AuxValues>
2.28 +
2.29 + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
2.30 + <SubComponents>
2.31 + <Container class="javax.swing.JPanel" name="jPanel1">
2.32 + <Properties>
2.33 + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
2.34 + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
2.35 + <EmptyBorder bottom="12" left="11" right="12" top="11"/>
2.36 + </Border>
2.37 + </Property>
2.38 + </Properties>
2.39 + <Constraints>
2.40 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
2.41 + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="1.0"/>
2.42 + </Constraint>
2.43 + </Constraints>
2.44 +
2.45 + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
2.46 + <SubComponents>
2.47 + <Component class="javax.swing.JTextArea" name="jTextArea1">
2.48 + <Properties>
2.49 + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
2.50 + <Color blue="cc" green="cc" id="Panel.background" palette="3" red="cc" type="palette"/>
2.51 + </Property>
2.52 + <Property name="editable" type="boolean" value="false"/>
2.53 + <Property name="lineWrap" type="boolean" value="true"/>
2.54 + <Property name="text" type="java.lang.String" value="Anagrams

Copyright (c) 2003 Irritable Enterprises, Inc."/>
2.55 + <Property name="wrapStyleWord" type="boolean" value="true"/>
2.56 + </Properties>
2.57 + <Constraints>
2.58 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
2.59 + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="12" insetsRight="0" anchor="10" weightX="1.0" weightY="1.0"/>
2.60 + </Constraint>
2.61 + </Constraints>
2.62 + </Component>
2.63 + <Component class="javax.swing.JButton" name="jButton1">
2.64 + <Properties>
2.65 + <Property name="text" type="java.lang.String" value="Close"/>
2.66 + </Properties>
2.67 + <Events>
2.68 + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
2.69 + </Events>
2.70 + <Constraints>
2.71 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
2.72 + <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
2.73 + </Constraint>
2.74 + </Constraints>
2.75 + </Component>
2.76 + </SubComponents>
2.77 + </Container>
2.78 + </SubComponents>
2.79 +</Form>
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/samples/componentinjection/anagram-modular/src-gui/org/apidesign/anagram/gui/About.java Sat Jun 14 10:06:53 2008 +0200
3.3 @@ -0,0 +1,91 @@
3.4 +package org.apidesign.anagram.gui;
3.5 +
3.6 +/**
3.7 + *
3.8 + * @author Dirk Ruiz
3.9 + */
3.10 +public class About extends javax.swing.JFrame {
3.11 +
3.12 + /** Creates new form About */
3.13 + public About() {
3.14 + initComponents();
3.15 + }
3.16 +
3.17 + /** This method is called from within the constructor to
3.18 + * initialize the form.
3.19 + * WARNING: Do NOT modify this code. The content of this method is
3.20 + * always regenerated by the Form Editor.
3.21 + */
3.22 + private void initComponents() {//GEN-BEGIN:initComponents
3.23 + java.awt.GridBagConstraints gridBagConstraints;
3.24 +
3.25 + jPanel1 = new javax.swing.JPanel();
3.26 + jTextArea1 = new javax.swing.JTextArea();
3.27 + jButton1 = new javax.swing.JButton();
3.28 +
3.29 + getContentPane().setLayout(new java.awt.GridBagLayout());
3.30 +
3.31 + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
3.32 + setTitle("About Anagrams");
3.33 + addWindowListener(new java.awt.event.WindowAdapter() {
3.34 + public void windowClosing(java.awt.event.WindowEvent evt) {
3.35 + exitForm(evt);
3.36 + }
3.37 + });
3.38 +
3.39 + jPanel1.setLayout(new java.awt.GridBagLayout());
3.40 +
3.41 + jPanel1.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(11, 11, 12, 12)));
3.42 + jTextArea1.setBackground((java.awt.Color) javax.swing.UIManager.getDefaults().get("Panel.background"));
3.43 + jTextArea1.setEditable(false);
3.44 + jTextArea1.setLineWrap(true);
3.45 + jTextArea1.setText("Anagrams\n\nCopyright (c) 2003 Irritable Enterprises, Inc.");
3.46 + jTextArea1.setToolTipText("null");
3.47 + jTextArea1.setWrapStyleWord(true);
3.48 + gridBagConstraints = new java.awt.GridBagConstraints();
3.49 + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
3.50 + gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 0);
3.51 + gridBagConstraints.weightx = 1.0;
3.52 + gridBagConstraints.weighty = 1.0;
3.53 + jPanel1.add(jTextArea1, gridBagConstraints);
3.54 +
3.55 + jButton1.setText("Close");
3.56 + jButton1.addActionListener(new java.awt.event.ActionListener() {
3.57 + public void actionPerformed(java.awt.event.ActionEvent evt) {
3.58 + jButton1ActionPerformed(evt);
3.59 + }
3.60 + });
3.61 +
3.62 + gridBagConstraints = new java.awt.GridBagConstraints();
3.63 + gridBagConstraints.gridx = 0;
3.64 + gridBagConstraints.gridy = 1;
3.65 + jPanel1.add(jButton1, gridBagConstraints);
3.66 +
3.67 + gridBagConstraints = new java.awt.GridBagConstraints();
3.68 + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
3.69 + gridBagConstraints.weightx = 1.0;
3.70 + gridBagConstraints.weighty = 1.0;
3.71 + getContentPane().add(jPanel1, gridBagConstraints);
3.72 +
3.73 + pack();
3.74 + java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
3.75 + setSize(new java.awt.Dimension(309, 231));
3.76 + setLocation((screenSize.width-309)/2,(screenSize.height-231)/2);
3.77 + }//GEN-END:initComponents
3.78 +
3.79 + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
3.80 + this.hide();
3.81 + }//GEN-LAST:event_jButton1ActionPerformed
3.82 +
3.83 + /** Exit the Application */
3.84 + private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
3.85 + //System.exit(0);
3.86 + }//GEN-LAST:event_exitForm
3.87 +
3.88 + // Variables declaration - do not modify//GEN-BEGIN:variables
3.89 + private javax.swing.JButton jButton1;
3.90 + private javax.swing.JTextArea jTextArea1;
3.91 + private javax.swing.JPanel jPanel1;
3.92 + // End of variables declaration//GEN-END:variables
3.93 +
3.94 +}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/samples/componentinjection/anagram-modular/src-gui/org/apidesign/anagram/gui/Anagrams.form Sat Jun 14 10:06:53 2008 +0200
4.3 @@ -0,0 +1,161 @@
4.4 +<?xml version="1.0" encoding="UTF-8" ?>
4.5 +
4.6 +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
4.7 + <NonVisualComponents>
4.8 + <Menu class="javax.swing.JMenuBar" name="mainMenu">
4.9 + <SubComponents>
4.10 + <Menu class="javax.swing.JMenu" name="File">
4.11 + <Properties>
4.12 + <Property name="text" type="java.lang.String" value="File"/>
4.13 + </Properties>
4.14 + <SubComponents>
4.15 + <MenuItem class="javax.swing.JMenuItem" name="jMenuItem1">
4.16 + <Properties>
4.17 + <Property name="text" type="java.lang.String" value="About"/>
4.18 + <Property name="toolTipText" type="java.lang.String" value="About"/>
4.19 + </Properties>
4.20 + <Events>
4.21 + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem1ActionPerformed"/>
4.22 + </Events>
4.23 + </MenuItem>
4.24 + <MenuItem class="javax.swing.JMenuItem" name="jMenuItem2">
4.25 + <Properties>
4.26 + <Property name="text" type="java.lang.String" value="Exit"/>
4.27 + <Property name="toolTipText" type="java.lang.String" value="Quit Team, Quit!"/>
4.28 + </Properties>
4.29 + <Events>
4.30 + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem2ActionPerformed"/>
4.31 + </Events>
4.32 + </MenuItem>
4.33 + </SubComponents>
4.34 + </Menu>
4.35 + </SubComponents>
4.36 + </Menu>
4.37 + </NonVisualComponents>
4.38 + <Properties>
4.39 + <Property name="title" type="java.lang.String" value="Anagrams"/>
4.40 + </Properties>
4.41 + <SyntheticProperties>
4.42 + <SyntheticProperty name="menuBar" type="java.lang.String" value="mainMenu"/>
4.43 + <SyntheticProperty name="formSize" 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,0,-6,0,0,1,-112"/>
4.44 + <SyntheticProperty name="formSizePolicy" type="int" value="0"/>
4.45 + <SyntheticProperty name="generateSize" type="boolean" value="true"/>
4.46 + <SyntheticProperty name="generateCenter" type="boolean" value="true"/>
4.47 + </SyntheticProperties>
4.48 + <Events>
4.49 + <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="exitForm"/>
4.50 + </Events>
4.51 + <AuxValues>
4.52 + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
4.53 + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
4.54 + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
4.55 + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
4.56 + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
4.57 + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
4.58 + </AuxValues>
4.59 +
4.60 + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
4.61 + <SubComponents>
4.62 + <Container class="javax.swing.JPanel" name="mainPanel">
4.63 + <Properties>
4.64 + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
4.65 + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
4.66 + <EmptyBorder bottom="12" left="11" right="12" top="11"/>
4.67 + </Border>
4.68 + </Property>
4.69 + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
4.70 + <Dimension value="[297, 200]"/>
4.71 + </Property>
4.72 + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
4.73 + <Dimension value="[297, 200]"/>
4.74 + </Property>
4.75 + </Properties>
4.76 + <Constraints>
4.77 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
4.78 + <BorderConstraints direction="Center"/>
4.79 + </Constraint>
4.80 + </Constraints>
4.81 +
4.82 + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
4.83 + <SubComponents>
4.84 + <Component class="javax.swing.JLabel" name="scrambledLabel">
4.85 + <Properties>
4.86 + <Property name="text" type="java.lang.String" value="Scrambled Word:"/>
4.87 + </Properties>
4.88 + <Constraints>
4.89 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
4.90 + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="12" insetsBottom="12" insetsRight="6" anchor="17" weightX="0.0" weightY="0.0"/>
4.91 + </Constraint>
4.92 + </Constraints>
4.93 + </Component>
4.94 + <Component class="javax.swing.JLabel" name="guessLabel">
4.95 + <Properties>
4.96 + <Property name="text" type="java.lang.String" value="Your Guess:"/>
4.97 + </Properties>
4.98 + <Constraints>
4.99 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
4.100 + <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="12" insetsBottom="12" insetsRight="6" anchor="17" weightX="0.0" weightY="0.0"/>
4.101 + </Constraint>
4.102 + </Constraints>
4.103 + </Component>
4.104 + <Component class="javax.swing.JLabel" name="feedbackLabel">
4.105 + <Properties>
4.106 + <Property name="text" type="java.lang.String" value=" "/>
4.107 + </Properties>
4.108 + <Constraints>
4.109 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
4.110 + <GridBagConstraints gridX="1" gridY="2" gridWidth="2" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="6" insetsRight="6" anchor="10" weightX="1.0" weightY="0.0"/>
4.111 + </Constraint>
4.112 + </Constraints>
4.113 + </Component>
4.114 + <Component class="javax.swing.JButton" name="guessButton">
4.115 + <Properties>
4.116 + <Property name="mnemonic" type="int" value="71"/>
4.117 + <Property name="text" type="java.lang.String" value="Guess"/>
4.118 + <Property name="toolTipText" type="java.lang.String" value="Guess the scrambled word."/>
4.119 + </Properties>
4.120 + <Events>
4.121 + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="guessedWordActionPerformed"/>
4.122 + </Events>
4.123 + <Constraints>
4.124 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
4.125 + <GridBagConstraints gridX="2" gridY="3" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="11" insetsRight="6" anchor="13" weightX="0.0" weightY="0.0"/>
4.126 + </Constraint>
4.127 + </Constraints>
4.128 + </Component>
4.129 + <Component class="javax.swing.JTextField" name="scrambledWord">
4.130 + <Properties>
4.131 + <Property name="editable" type="boolean" value="false"/>
4.132 + </Properties>
4.133 + <Constraints>
4.134 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
4.135 + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="3" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="0" insetsBottom="12" insetsRight="11" anchor="10" weightX="1.0" weightY="0.0"/>
4.136 + </Constraint>
4.137 + </Constraints>
4.138 + </Component>
4.139 + <Component class="javax.swing.JTextField" name="guessedWord">
4.140 + <Constraints>
4.141 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
4.142 + <GridBagConstraints gridX="1" gridY="1" gridWidth="3" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="12" insetsRight="11" anchor="10" weightX="1.0" weightY="0.0"/>
4.143 + </Constraint>
4.144 + </Constraints>
4.145 + </Component>
4.146 + <Component class="javax.swing.JButton" name="nextTrial">
4.147 + <Properties>
4.148 + <Property name="mnemonic" type="int" value="78"/>
4.149 + <Property name="text" type="java.lang.String" value="New Word"/>
4.150 + <Property name="toolTipText" type="java.lang.String" value="Fetch a new word."/>
4.151 + </Properties>
4.152 + <Events>
4.153 + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="nextTrialActionPerformed"/>
4.154 + </Events>
4.155 + <Constraints>
4.156 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
4.157 + <GridBagConstraints gridX="3" gridY="3" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="11" insetsRight="11" anchor="10" weightX="0.0" weightY="0.0"/>
4.158 + </Constraint>
4.159 + </Constraints>
4.160 + </Component>
4.161 + </SubComponents>
4.162 + </Container>
4.163 + </SubComponents>
4.164 +</Form>
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/samples/componentinjection/anagram-modular/src-gui/org/apidesign/anagram/gui/Anagrams.java Sat Jun 14 10:06:53 2008 +0200
5.3 @@ -0,0 +1,237 @@
5.4 +package org.apidesign.anagram.gui;
5.5 +
5.6 +import org.apidesign.anagram.api.Scrambler;
5.7 +import org.apidesign.anagram.api.UI;
5.8 +import org.apidesign.anagram.api.WordLibrary;
5.9 +
5.10 +/** Modified version of classical NetBeans Anagrams example for purposes
5.11 + * of modular world.
5.12 + *
5.13 + * @author Dirk Ruiz, Jaroslav Tulach
5.14 + */
5.15 +public abstract class Anagrams extends javax.swing.JFrame implements UI {
5.16 + int wordIdx = 0;
5.17 + String original;
5.18 + String scrambled;
5.19 +
5.20 +
5.21 + /** Creates new form Anagrams */
5.22 + public Anagrams() {
5.23 + initComponents();
5.24 + initWord();
5.25 + getRootPane().setDefaultButton(guessButton);
5.26 + }
5.27 +
5.28 + protected abstract WordLibrary getWordLibrary();
5.29 + protected abstract Scrambler getScrambler();
5.30 +
5.31 + /** This method is called from within the constructor to
5.32 + * initialize the form.
5.33 + * WARNING: Do NOT modify this code. The content of this method is
5.34 + * always regenerated by the Form Editor.
5.35 + */
5.36 + private void initComponents() {//GEN-BEGIN:initComponents
5.37 + java.awt.GridBagConstraints gridBagConstraints;
5.38 +
5.39 + mainPanel = new javax.swing.JPanel();
5.40 + scrambledLabel = new javax.swing.JLabel();
5.41 + guessLabel = new javax.swing.JLabel();
5.42 + feedbackLabel = new javax.swing.JLabel();
5.43 + guessButton = new javax.swing.JButton();
5.44 + scrambledWord = new javax.swing.JTextField();
5.45 + guessedWord = new javax.swing.JTextField();
5.46 + nextTrial = new javax.swing.JButton();
5.47 + mainMenu = new javax.swing.JMenuBar();
5.48 + File = new javax.swing.JMenu();
5.49 + jMenuItem1 = new javax.swing.JMenuItem();
5.50 + jMenuItem2 = new javax.swing.JMenuItem();
5.51 +
5.52 + setTitle("Anagrams");
5.53 + addWindowListener(new java.awt.event.WindowAdapter() {
5.54 + public void windowClosing(java.awt.event.WindowEvent evt) {
5.55 + exitForm(evt);
5.56 + }
5.57 + });
5.58 +
5.59 + mainPanel.setLayout(new java.awt.GridBagLayout());
5.60 +
5.61 + mainPanel.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(11, 11, 12, 12)));
5.62 + mainPanel.setMinimumSize(new java.awt.Dimension(297, 200));
5.63 + mainPanel.setPreferredSize(new java.awt.Dimension(297, 200));
5.64 + scrambledLabel.setText("Scrambled Word:");
5.65 + gridBagConstraints = new java.awt.GridBagConstraints();
5.66 + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
5.67 + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
5.68 + gridBagConstraints.insets = new java.awt.Insets(12, 12, 12, 6);
5.69 + mainPanel.add(scrambledLabel, gridBagConstraints);
5.70 +
5.71 + guessLabel.setText("Your Guess:");
5.72 + gridBagConstraints = new java.awt.GridBagConstraints();
5.73 + gridBagConstraints.gridx = 0;
5.74 + gridBagConstraints.gridy = 1;
5.75 + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
5.76 + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
5.77 + gridBagConstraints.insets = new java.awt.Insets(0, 12, 12, 6);
5.78 + mainPanel.add(guessLabel, gridBagConstraints);
5.79 +
5.80 + feedbackLabel.setText(" ");
5.81 + gridBagConstraints = new java.awt.GridBagConstraints();
5.82 + gridBagConstraints.gridx = 1;
5.83 + gridBagConstraints.gridy = 2;
5.84 + gridBagConstraints.gridwidth = 2;
5.85 + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
5.86 + gridBagConstraints.weightx = 1.0;
5.87 + gridBagConstraints.insets = new java.awt.Insets(0, 0, 6, 6);
5.88 + mainPanel.add(feedbackLabel, gridBagConstraints);
5.89 +
5.90 + guessButton.setMnemonic('G');
5.91 + guessButton.setText("Guess");
5.92 + guessButton.setToolTipText("Guess the scrambled word.");
5.93 + guessButton.addActionListener(new java.awt.event.ActionListener() {
5.94 + public void actionPerformed(java.awt.event.ActionEvent evt) {
5.95 + guessedWordActionPerformed(evt);
5.96 + }
5.97 + });
5.98 +
5.99 + gridBagConstraints = new java.awt.GridBagConstraints();
5.100 + gridBagConstraints.gridx = 2;
5.101 + gridBagConstraints.gridy = 3;
5.102 + gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
5.103 + gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 6);
5.104 + mainPanel.add(guessButton, gridBagConstraints);
5.105 +
5.106 + scrambledWord.setEditable(false);
5.107 + gridBagConstraints = new java.awt.GridBagConstraints();
5.108 + gridBagConstraints.gridwidth = 3;
5.109 + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
5.110 + gridBagConstraints.weightx = 1.0;
5.111 + gridBagConstraints.insets = new java.awt.Insets(12, 0, 12, 11);
5.112 + mainPanel.add(scrambledWord, gridBagConstraints);
5.113 +
5.114 + gridBagConstraints = new java.awt.GridBagConstraints();
5.115 + gridBagConstraints.gridx = 1;
5.116 + gridBagConstraints.gridy = 1;
5.117 + gridBagConstraints.gridwidth = 3;
5.118 + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
5.119 + gridBagConstraints.weightx = 1.0;
5.120 + gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 11);
5.121 + mainPanel.add(guessedWord, gridBagConstraints);
5.122 +
5.123 + nextTrial.setMnemonic('N');
5.124 + nextTrial.setText("New Word");
5.125 + nextTrial.setToolTipText("Fetch a new word.");
5.126 + nextTrial.addActionListener(new java.awt.event.ActionListener() {
5.127 + public void actionPerformed(java.awt.event.ActionEvent evt) {
5.128 + nextTrialActionPerformed(evt);
5.129 + }
5.130 + });
5.131 +
5.132 + gridBagConstraints = new java.awt.GridBagConstraints();
5.133 + gridBagConstraints.gridx = 3;
5.134 + gridBagConstraints.gridy = 3;
5.135 + gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
5.136 + mainPanel.add(nextTrial, gridBagConstraints);
5.137 +
5.138 + getContentPane().add(mainPanel, java.awt.BorderLayout.CENTER);
5.139 +
5.140 + File.setText("File");
5.141 + jMenuItem1.setText("About");
5.142 + jMenuItem1.setToolTipText("About");
5.143 + jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
5.144 + public void actionPerformed(java.awt.event.ActionEvent evt) {
5.145 + jMenuItem1ActionPerformed(evt);
5.146 + }
5.147 + });
5.148 +
5.149 + File.add(jMenuItem1);
5.150 +
5.151 + jMenuItem2.setText("Exit");
5.152 + jMenuItem2.setToolTipText("Quit Team, Quit!");
5.153 + jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
5.154 + public void actionPerformed(java.awt.event.ActionEvent evt) {
5.155 + jMenuItem2ActionPerformed(evt);
5.156 + }
5.157 + });
5.158 +
5.159 + File.add(jMenuItem2);
5.160 +
5.161 + mainMenu.add(File);
5.162 +
5.163 + setJMenuBar(mainMenu);
5.164 +
5.165 + java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
5.166 + setBounds((screenSize.width-400)/2, (screenSize.height-250)/2, 400, 250);
5.167 + }//GEN-END:initComponents
5.168 +
5.169 + private void nextTrialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nextTrialActionPerformed
5.170 + wordIdx++;
5.171 +
5.172 + feedbackLabel.setText(" ");
5.173 + initWord();
5.174 + guessedWord.setText("");
5.175 + getRootPane().setDefaultButton(guessButton);
5.176 +
5.177 + guessedWord.requestFocus();
5.178 + }//GEN-LAST:event_nextTrialActionPerformed
5.179 +
5.180 + private void initWord() {
5.181 +
5.182 + String[] words = getWordLibrary().getWords();
5.183 + int index = wordIdx % words.length;
5.184 +
5.185 + original = words[index];
5.186 + scrambled = getScrambler().scramble(original);
5.187 +
5.188 + scrambledWord.setText(scrambled);
5.189 + }
5.190 +
5.191 + private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
5.192 + System.exit(0);
5.193 + }//GEN-LAST:event_jMenuItem2ActionPerformed
5.194 +
5.195 + private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
5.196 + new About().show();
5.197 + }//GEN-LAST:event_jMenuItem1ActionPerformed
5.198 +
5.199 + private void guessedWordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_guessedWordActionPerformed
5.200 +
5.201 + if(guessedWord.getText().equals(original)) {
5.202 + feedbackLabel.setText("Correct! Try a new word!");
5.203 + getRootPane().setDefaultButton(nextTrial);
5.204 + } else {
5.205 + feedbackLabel.setText("Incorrect! Try again!");
5.206 + guessedWord.setText("");
5.207 + }
5.208 +
5.209 + guessedWord.requestFocus();
5.210 + }//GEN-LAST:event_guessedWordActionPerformed
5.211 +
5.212 + /** Exit the Application */
5.213 + private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
5.214 + System.exit(0);
5.215 + }//GEN-LAST:event_exitForm
5.216 +
5.217 + @Override
5.218 + public void setVisible(boolean v) {
5.219 + super.setVisible(v);
5.220 + if (v) {
5.221 + guessedWord.requestFocus();
5.222 + }
5.223 + }
5.224 +
5.225 + // Variables declaration - do not modify//GEN-BEGIN:variables
5.226 + private javax.swing.JMenu File;
5.227 + private javax.swing.JLabel feedbackLabel;
5.228 + private javax.swing.JButton guessButton;
5.229 + private javax.swing.JLabel guessLabel;
5.230 + private javax.swing.JTextField guessedWord;
5.231 + private javax.swing.JMenuItem jMenuItem1;
5.232 + private javax.swing.JMenuItem jMenuItem2;
5.233 + private javax.swing.JMenuBar mainMenu;
5.234 + private javax.swing.JPanel mainPanel;
5.235 + private javax.swing.JButton nextTrial;
5.236 + private javax.swing.JLabel scrambledLabel;
5.237 + private javax.swing.JTextField scrambledWord;
5.238 + // End of variables declaration//GEN-END:variables
5.239 +
5.240 +}