-
Notifications
You must be signed in to change notification settings - Fork 100
/
FloatPanel.java
107 lines (93 loc) · 4.02 KB
/
FloatPanel.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* NumberPanel.java
*
* Created on 14.06.2010, 16:42:25
*/
package com.jme3.gde.materials.multiview.widgets;
import com.jme3.gde.materials.MaterialProperty;
/**
*
* @author normenhansen
*/
public class FloatPanel extends MaterialPropertyWidget {
/** Creates new form NumberPanel */
public FloatPanel() {
initComponents();
jSpinner1.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.0f), null, null, Float.valueOf(0.1f)));
}
/** 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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jToolBar1 = new javax.swing.JToolBar();
jLabel1 = new javax.swing.JLabel();
filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(20, 0), new java.awt.Dimension(32767, 0));
jSpinner1 = new javax.swing.JSpinner();
setMinimumSize(new java.awt.Dimension(100, 27));
jToolBar1.setRollover(true);
jToolBar1.setPreferredSize(new java.awt.Dimension(159, 27));
jLabel1.setText(org.openide.util.NbBundle.getMessage(FloatPanel.class, "FloatPanel.jLabel1.text")); // NOI18N
jLabel1.setMaximumSize(new java.awt.Dimension(300, 16));
jLabel1.setMinimumSize(new java.awt.Dimension(10, 17));
jToolBar1.add(jLabel1);
jToolBar1.add(filler1);
jSpinner1.setModel(new javax.swing.SpinnerNumberModel(0.0f, null, null, 1.0f));
jSpinner1.setMaximumSize(new java.awt.Dimension(100, 23));
jSpinner1.setMinimumSize(new java.awt.Dimension(30, 23));
jSpinner1.setPreferredSize(new java.awt.Dimension(100, 23));
jSpinner1.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
valueChanged(evt);
}
});
jToolBar1.add(jSpinner1);
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, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
);
}// </editor-fold>//GEN-END:initComponents
private void valueChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_valueChanged
if (property == null) {
return;
}
property.setValue(jSpinner1.getValue() + "");
fireChanged();
}//GEN-LAST:event_valueChanged
@Override
protected void readProperty() {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
jLabel1.setText(property.getName());
jLabel1.setToolTipText(property.getName());
MaterialProperty prop = property;
property = null;
try {
jSpinner1.setValue(Float.parseFloat(prop.getValue()));
} catch (Exception e) {
jSpinner1.setValue(0);
}
property = prop;
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.Box.Filler filler1;
private javax.swing.JLabel jLabel1;
private javax.swing.JSpinner jSpinner1;
private javax.swing.JToolBar jToolBar1;
// End of variables declaration//GEN-END:variables
}