Mp3dings 
20100427

de.mospace.swing.text
Class HistoryTextField

java.lang.Object
  extended by de.mospace.swing.text.HistoryTextField

public class HistoryTextField
extends Object

A text field that remembers the last values entered. The GUI representation is actually a JComboBox that can be retrieved with the getJComboBox method.

Version:
$Revision: 12 $ ($Date: 2007-07-27 11:48:53 +0200 (Fr, 27 Jul 2007) $)
Author:
Moritz Ringler

Constructor Summary
HistoryTextField(Preferences prefNode, int id)
          Constructs a HistoryTextField with the specified id and initializes it with all previously saved values.
HistoryTextField(Preferences prefNode, int id, int len)
          Constructs a HistoryTextField with the specified id and initializes it with at most len previously saved values.
 
Method Summary
 void addCurrentItem()
          Adds the item that is currently edited to this text field's history.
 void addToHistory(String str)
          Adds a new string to this text field's history.
 void clearHistory()
          Clears this text field's history.
 JComboBox getComboBox()
          Gets the single JComboBox object that serves as a GUI representation of this history text field.
 String[] getStringArray()
          Returns the items in this text field's history as a newly allocated String array.
 boolean isAutoSave()
          Returns whether items newly added to this text field's combo box will automatically be added to the history and saved under the preference node and id that this text field has been loaded from.
 void save(Preferences prefNode, int id)
          Saves this text fields history to the specified preference node and id.
 void setAutoSave(boolean b)
          Sets whether items newly added to this text field's combo box will automatically be added to the history and saved under the preference node and id that this text field has been loaded from.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HistoryTextField

public HistoryTextField(Preferences prefNode,
                        int id,
                        int len)
Constructs a HistoryTextField with the specified id and initializes it with at most len previously saved values.

Parameters:
prefNode - the preference node that values will be loaded from
id - an integer identifying the history text field whose values to load
len - the maximum number of values to load from the preferences, if it is {0 | negative} then {all | no} saved values will be loaded

HistoryTextField

public HistoryTextField(Preferences prefNode,
                        int id)
Constructs a HistoryTextField with the specified id and initializes it with all previously saved values.

Parameters:
prefNode - the preference node that values will be loaded from
id - an integer identifying this history text field whose values to load
Method Detail

save

public void save(Preferences prefNode,
                 int id)
Saves this text fields history to the specified preference node and id.

Parameters:
prefNode - the preference node that values will be written to
id - an integer identifying this history text field

addToHistory

public void addToHistory(String str)
Adds a new string to this text field's history.

Parameters:
str - the string to add

addCurrentItem

public void addCurrentItem()
Adds the item that is currently edited to this text field's history.


clearHistory

public void clearHistory()
Clears this text field's history.


getComboBox

public JComboBox getComboBox()
Gets the single JComboBox object that serves as a GUI representation of this history text field.

Returns:
the combo box for this history text field
See Also:
setAutoSave(boolean)

setAutoSave

public void setAutoSave(boolean b)
Sets whether items newly added to this text field's combo box will automatically be added to the history and saved under the preference node and id that this text field has been loaded from.

Parameters:
b - whether new items should be saved automatically
See Also:
isAutoSave()

isAutoSave

public boolean isAutoSave()
Returns whether items newly added to this text field's combo box will automatically be added to the history and saved under the preference node and id that this text field has been loaded from.

Returns:
whether new items are saved automatically
See Also:
setAutoSave(boolean)

getStringArray

public String[] getStringArray()
Returns the items in this text field's history as a newly allocated String array.

Returns:
this text field's history

Mp3dings 
20100427