From d216390a00df23db3382a6cdd025563d6706a704 Mon Sep 17 00:00:00 2001 From: "rem..om" Date: Sat, 6 Aug 2011 16:39:50 +0000 Subject: [PATCH] sdk : - You can now select a texture in texture browser by double clicking it git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7986 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../gde/core/properties/TextureBrowser.form | 7 +++- .../gde/core/properties/TextureBrowser.java | 40 +++++++++++++------ 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/sdk/jme3-core/src/com/jme3/gde/core/properties/TextureBrowser.form b/sdk/jme3-core/src/com/jme3/gde/core/properties/TextureBrowser.form index f988832c4..44a11e516 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/properties/TextureBrowser.form +++ b/sdk/jme3-core/src/com/jme3/gde/core/properties/TextureBrowser.form @@ -55,6 +55,9 @@ + + + @@ -70,7 +73,7 @@ - + @@ -119,7 +122,7 @@ - + diff --git a/sdk/jme3-core/src/com/jme3/gde/core/properties/TextureBrowser.java b/sdk/jme3-core/src/com/jme3/gde/core/properties/TextureBrowser.java index 3bd5d3d01..a03c16164 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/properties/TextureBrowser.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/properties/TextureBrowser.java @@ -37,6 +37,7 @@ import com.jme3.gde.core.util.TreeUtil; import com.jme3.texture.Texture; import java.awt.Color; import java.awt.Graphics2D; +import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; @@ -101,6 +102,11 @@ public class TextureBrowser extends javax.swing.JDialog implements TreeSelection setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle(org.openide.util.NbBundle.getMessage(TextureBrowser.class, "TextureBrowser.title")); // NOI18N + jTree1.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jTree1MouseClicked(evt); + } + }); jScrollPane3.setViewportView(jTree1); imagePreviewLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); @@ -115,13 +121,13 @@ public class TextureBrowser extends javax.swing.JDialog implements TreeSelection jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(infoLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 488, Short.MAX_VALUE) - .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 488, Short.MAX_VALUE) + .addComponent(infoLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 553, Short.MAX_VALUE) + .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 553, Short.MAX_VALUE) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() - .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 412, Short.MAX_VALUE) + .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 420, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(infoLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)) ); @@ -147,7 +153,7 @@ public class TextureBrowser extends javax.swing.JDialog implements TreeSelection .addGroup(jPanel3Layout.createSequentialGroup() .addContainerGap() .addComponent(cancelButton) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 358, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 423, Short.MAX_VALUE) .addComponent(okButton) .addContainerGap()) ); @@ -157,7 +163,7 @@ public class TextureBrowser extends javax.swing.JDialog implements TreeSelection .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cancelButton) .addComponent(okButton)) - .addContainerGap(11, Short.MAX_VALUE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); @@ -177,22 +183,31 @@ public class TextureBrowser extends javax.swing.JDialog implements TreeSelection .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 477, Short.MAX_VALUE) + .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 485, Short.MAX_VALUE) ); pack(); }// //GEN-END:initComponents private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed - setTexture(); - dispose(); + if (setTexture()) { + dispose(); + } }//GEN-LAST:event_okButtonActionPerformed private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed dispose(); }//GEN-LAST:event_cancelButtonActionPerformed - private void setTexture() { +private void jTree1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTree1MouseClicked + if (evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() == 2) { + if (setTexture()) { + dispose(); + } + } +}//GEN-LAST:event_jTree1MouseClicked + + private boolean setTexture() { DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent(); //Object nodeInfo = node.getUserObject(); @@ -202,10 +217,11 @@ public class TextureBrowser extends javax.swing.JDialog implements TreeSelection Texture tex = assetManager.loadTexture(selected); editor.setValue(tex); editor.setAsText(selected); - } else { - editor.setValue(null); - editor.setAsText(null); + return true; } + return false; + + // if (textureList.getSelectedIndex() > -1) { // textureList.getSelectedValue(); // String selected = (String) textureList.getSelectedValue();