OSDN Git Service

meven
[hayashilib/hayashi.git] / src / main / java / hayashi / yuu / tools / properties / PropertyFieldItem.java
diff --git a/src/main/java/hayashi/yuu/tools/properties/PropertyFieldItem.java b/src/main/java/hayashi/yuu/tools/properties/PropertyFieldItem.java
new file mode 100755 (executable)
index 0000000..36d2657
--- /dev/null
@@ -0,0 +1,48 @@
+package hayashi.yuu.tools.properties;\r
+\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.FocusEvent;\r
+import java.awt.event.FocusListener;\r
+import javax.swing.JTextField;\r
+\r
+@SuppressWarnings("serial")\r
+public class PropertyFieldItem extends PropertyItem implements FocusListener\r
+{\r
+       public PropertyFieldItem(hayashi.yuu.tools.properties.Properties prop, String name, String title, boolean editable) {\r
+               super(prop, name, title);\r
+               field = new JTextField(value, 20);\r
+               ((JTextField)field).addFocusListener(this);\r
+               createItem(name, title, prop.getProperty(name), editable);\r
+       }\r
+\r
+       @Override\r
+       void setupField(String name, String value, boolean editable) {\r
+               this.value = value;\r
+               ((JTextField)field).setText(value);\r
+               if (!editable) {\r
+                       field.setEnabled(editable);\r
+               }\r
+               add(field);\r
+       }\r
+\r
+       @Override\r
+       public void actionPerformed(ActionEvent e) {\r
+               this.value = ((JTextField)this.field).getText();\r
+               logger.info("[反映] "+ propertyName +" = "+ this.value);\r
+               prop.setProperty(propertyName, this.value);\r
+       }\r
+\r
+       /**\r
+        * このフィールドにカーソルが移ったときの処理\r
+        */\r
+       public void focusGained(FocusEvent arg0) {\r
+               // 何もしない\r
+       }\r
+\r
+       /**\r
+        * このフィールドから他のフィールドへカーソルが移った時の処理。\r
+        */\r
+       public void focusLost(FocusEvent arg0) {\r
+               actionPerformed(null);\r
+       }\r
+}\r