1 package rero.dck.items; 2 3 import java.awt.*; 4 import java.awt.event.*; 5 6 import javax.swing.*; 7 import javax.swing.event.*; 8 9 import java.util.*; 10 11 import java.io.*; 12 13 import rero.dck.*; 14 import rero.config.*; 15 16 public class TextInput extends SuperInput implements ActionListener 17 { 18 protected JEditorPane text; 19 20 public TextInput(String _variable, int inset) 21 { 22 text = new JEditorPane(); 23 setLayout(new BorderLayout(2, 2)); 24 25 add(new JScrollPane(text), BorderLayout.CENTER); 26 27 variable = _variable; 28 29 setBorder(BorderFactory.createEmptyBorder(0, inset, 0, inset)); 30 } 31 32 public void actionPerformed(ActionEvent ev) 33 { 34 text.setText(""); 35 } 36 37 public void save() 38 { 39 String [] blah = text.getText().split("\n"); 40 41 StringList temp = new StringList(getVariable()); 42 temp.clear(); 43 44 for (int x = 0; x < blah.length; x++) 45 { 46 temp.add(blah[x]); 47 } 48 49 temp.save(); 50 } 51 52 public int getEstimatedWidth() 53 { 54 return -1; 55 } 56 57 public void setAlignWidth(int width) 58 { 59 } 60 61 public JComponent getComponent() 62 { 63 return this; 64 } 65 66 public void refresh() 67 { 68 StringList string = ClientState.getClientState().getStringList(getVariable()); 69 StringBuffer data = new StringBuffer (); 70 71 Iterator i = string.getList().iterator(); 72 while (i.hasNext()) 73 { 74 data.append(i.next()); 75 data.append("\n"); 76 } 77 78 text.setText(data.toString()); 79 text.setCaretPosition(0); 80 } 81 } 82 83 84 | Popular Tags |