KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > suberic > util > gui > propedit > TextMessageEditorPane


1 package net.suberic.util.gui.propedit;
2 import javax.swing.*;
3 import net.suberic.util.*;
4
5 /**
6  * An EditorPane which actually just displays some text.
7  *
8  */

9 public class TextMessageEditorPane extends SwingPropertyEditor {
10   protected JTextArea textArea;
11
12
13   /**
14    * @param propertyName The property to be edited.
15    * @param template The property that will define the layout of the
16    * editor.
17    * @param manager The PropertyEditorManager that will manage the
18    * changes.
19    */

20   public void configureEditor(String JavaDoc propertyName, String JavaDoc template, String JavaDoc propertyBaseName, PropertyEditorManager newManager) {
21     configureBasic(propertyName, template, propertyBaseName, newManager);
22
23     String JavaDoc defaultLabel;
24     int dotIndex = editorTemplate.lastIndexOf(".");
25     if (dotIndex == -1)
26       defaultLabel = new String JavaDoc(editorTemplate);
27     else
28       defaultLabel = property.substring(dotIndex+1);
29
30     //JLabel mainLabel = new JLabel(manager.getProperty(editorTemplate + ".label", defaultLabel));
31

32     //this.add(mainLabel);
33
this.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), manager.getProperty(editorTemplate + ".label", defaultLabel)));
34     //System.err.println("radioeditorpane: mainLabel = " + mainLabel.getText());
35
//layout.putConstraint(SpringLayout.WEST, mainLabel, 0, SpringLayout.WEST, this);
36
//layout.putConstraint(SpringLayout.NORTH, mainLabel, 0, SpringLayout.NORTH, this);
37

38     //label = new JLabel(manager.getProperty(editorTemplate + ".message", "No message."));
39
//this.add(label);
40
textArea = new JTextArea(manager.getProperty(editorTemplate + ".message", "No message."));
41     textArea.setEditable(false);
42     JLabel testLab = new JLabel();
43     textArea.setBackground(testLab.getBackground());
44     textArea.setFont(testLab.getFont());
45     this.add(textArea);
46
47   }
48
49   /**
50    * This writes the currently configured value in the PropertyEditorUI
51    * to the source VariableBundle.
52    *
53    * A no-op in this case.
54    */

55   public void setValue() {
56
57   }
58
59   /**
60    * This writes the currently configured value in the PropertyEditorUI
61    * to the source VariableBundle.
62    *
63    * A no-op in this case.
64    */

65   public void validateProperty() {
66
67   }
68
69   /**
70    * Returns the current values of the edited properties as a
71    * java.util.Properties object.
72    *
73    * This implementation returns an empty array.
74    */

75   public java.util.Properties JavaDoc getValue() {
76     java.util.Properties JavaDoc retProps = new java.util.Properties JavaDoc();
77
78     return retProps;
79   }
80
81   /**
82    * This resets the editor to the original (or latest set, if setValue()
83    * has been called) value of the edited property.
84    */

85   public void resetDefaultValue() {
86   }
87
88   /**
89    * Selects the given value.
90    */

91   public void setSelectedValue(String JavaDoc newValue) {
92   }
93
94   /**
95    * Returns whether or not the current list selection has changed from
96    * the last save.
97    */

98   public boolean isChanged() {
99     return false;
100   }
101
102   /**
103    * Run when the PropertyEditor may have changed enabled states.
104    */

105   protected void updateEditorEnabled() {
106     if (textArea != null)
107       textArea.setEnabled(isEnabled());
108   }
109
110   /**
111    * Gets the parent PropertyEditorPane for the given component.
112    */

113   public PropertyEditorPane getPropertyEditorPane() {
114     return getPropertyEditorPane(this);
115   }
116
117   /**
118    * Returns the display value for this property.
119    */

120   public String JavaDoc getDisplayValue() {
121     return getProperty();
122   }
123
124 }
125
Popular Tags