- 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
3.0
rem..om 14 years ago
parent b035d52fa2
commit d216390a00
  1. 7
      sdk/jme3-core/src/com/jme3/gde/core/properties/TextureBrowser.form
  2. 40
      sdk/jme3-core/src/com/jme3/gde/core/properties/TextureBrowser.java

@ -55,6 +55,9 @@
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTree" name="jTree1">
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jTree1MouseClicked"/>
</Events>
</Component>
</SubComponents>
</Container>
@ -70,7 +73,7 @@
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="jScrollPane2" pref="412" max="32767" attributes="1"/>
<Component id="jScrollPane2" pref="420" max="32767" attributes="1"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="infoLabel" min="-2" pref="19" max="-2" attributes="0"/>
</Group>
@ -119,7 +122,7 @@
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="358" max="32767" attributes="0"/>
<EmptySpace pref="423" max="32767" attributes="0"/>
<Component id="okButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>

@ -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();
}// </editor-fold>//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();

Loading…
Cancel
Save