OSDN Git Service

SDK :
authorremy.bouquet@gmail.com <remy.bouquet@gmail.com@75d07b2b-3a1a-0410-a2c5-0572b91ccdca>
Mon, 1 Aug 2011 22:50:25 +0000 (22:50 +0000)
committerremy.bouquet@gmail.com <remy.bouquet@gmail.com@75d07b2b-3a1a-0410-a2c5-0572b91ccdca>
Mon, 1 Aug 2011 22:50:25 +0000 (22:50 +0000)
- Material editor : made TextPanel widget to trigger property change when the field looses focus. It was only triggering it when you pressed enter in the field. (at least on Windows 7, it can be different on other OS)

git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@7965 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/TextPanel.form
sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/TextPanel.java

index e56c027..350a691 100644 (file)
@@ -21,7 +21,7 @@
   <Layout>
     <DimensionLayout dim="0">
       <Group type="103" groupAlignment="0" attributes="0">
-          <Component id="jToolBar1" alignment="0" pref="185" max="32767" attributes="0"/>
+          <Component id="jToolBar1" alignment="0" pref="638" max="32767" attributes="0"/>
       </Group>
     </DimensionLayout>
     <DimensionLayout dim="1">
             <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
               <ResourceString bundle="com/jme3/gde/materials/multiview/widgets/Bundle.properties" key="TextPanel.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
             </Property>
+            <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[60, 14]"/>
+            </Property>
+            <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[60, 14]"/>
+            </Property>
             <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
               <Dimension value="[100, 16]"/>
             </Property>
@@ -65,7 +71,7 @@
           <Layout>
             <DimensionLayout dim="0">
               <Group type="103" groupAlignment="0" attributes="0">
-                  <EmptySpace min="0" pref="4" max="32767" attributes="0"/>
+                  <EmptySpace min="0" pref="336" max="32767" attributes="0"/>
               </Group>
             </DimensionLayout>
             <DimensionLayout dim="1">
@@ -89,6 +95,8 @@
           </Properties>
           <Events>
             <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="textChanged"/>
+            <EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jTextField1FocusLost"/>
+            <EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="jTextField1KeyTyped"/>
           </Events>
         </Component>
       </SubComponents>
index 6b4a3ba..182251a 100644 (file)
@@ -46,6 +46,8 @@ public class TextPanel extends MaterialPropertyWidget {
         jToolBar1.setRollover(true);
 
         jLabel1.setText(org.openide.util.NbBundle.getMessage(TextPanel.class, "TextPanel.jLabel1.text")); // NOI18N
+        jLabel1.setMaximumSize(new java.awt.Dimension(60, 14));
+        jLabel1.setMinimumSize(new java.awt.Dimension(60, 14));
         jLabel1.setPreferredSize(new java.awt.Dimension(100, 16));
         jToolBar1.add(jLabel1);
 
@@ -56,7 +58,7 @@ public class TextPanel extends MaterialPropertyWidget {
         jPanel1.setLayout(jPanel1Layout);
         jPanel1Layout.setHorizontalGroup(
             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addGap(0, 4, Short.MAX_VALUE)
+            .addGap(0, 336, Short.MAX_VALUE)
         );
         jPanel1Layout.setVerticalGroup(
             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -73,13 +75,23 @@ public class TextPanel extends MaterialPropertyWidget {
                 textChanged(evt);
             }
         });
+        jTextField1.addFocusListener(new java.awt.event.FocusAdapter() {
+            public void focusLost(java.awt.event.FocusEvent evt) {
+                jTextField1FocusLost(evt);
+            }
+        });
+        jTextField1.addKeyListener(new java.awt.event.KeyAdapter() {
+            public void keyTyped(java.awt.event.KeyEvent evt) {
+                jTextField1KeyTyped(evt);
+            }
+        });
         jToolBar1.add(jTextField1);
 
         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
         this.setLayout(layout);
         layout.setHorizontalGroup(
             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE)
+            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 638, Short.MAX_VALUE)
         );
         layout.setVerticalGroup(
             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -88,10 +100,19 @@ public class TextPanel extends MaterialPropertyWidget {
     }// </editor-fold>//GEN-END:initComponents
 
     private void textChanged(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textChanged
-        property.setValue(jTextField1.getText());
+        property.setValue(jTextField1.getText());     
         fireChanged();
     }//GEN-LAST:event_textChanged
 
+private void jTextField1KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField1KeyTyped
+// TODO add your handling code here:
+}//GEN-LAST:event_jTextField1KeyTyped
+
+private void jTextField1FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField1FocusLost
+        property.setValue(jTextField1.getText());
+        fireChanged();
+}//GEN-LAST:event_jTextField1FocusLost
+
     @Override
     protected void readProperty() {
         java.awt.EventQueue.invokeLater(new Runnable() {
@@ -99,7 +120,8 @@ public class TextPanel extends MaterialPropertyWidget {
             public void run() {
                 jLabel1.setToolTipText(property.getName() + " (" + property.getType() + ")");
                 jLabel1.setText(property.getName() + " (" + property.getType() + ")");
-                jTextField1.setText(property.getValue());
+                 
+                jTextField1.setText(property.getValue());               
             }
         });
     }