com.cbse.jeasy
Class JEComboBox

java.lang.Object
  extended by com.cbse.jeasy.JEObject
      extended by com.cbse.jeasy.JEComboBox
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.FocusListener, java.awt.event.ItemListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.util.EventListener

public class JEComboBox
extends JEObject
implements java.awt.event.FocusListener, java.awt.event.ActionListener, java.awt.event.KeyListener, java.awt.event.ItemListener, java.awt.event.MouseListener

A class using a JLabel a JComboBox and a JButton. In Swing you can addItems to a combobox. In JEasy the JECombobox can held an optional value you can set with addItemAndValue(..).

Properties
name values comment
id * Id of the object. Let it begin with CB_
button true
false
Set true will set a button behind the field, which will send the id of the JEComboBox as an ActionCommand to the callBack
name   It is the name of the label of the ComboBox.
border   Id of a border.
background Id of a color used as the background
tooltip   Text in Tooltip
XMLtag*The tagname used to serialize the item in xml format.
XMLValuetag*The tagname used to serialize the value in xml format.
mandatory true
false
Defines an entry as mandatory
labelConstraints   Constraints for JLabel
textfieldConstraints   Constraints for JTextField
visible true
false
Set to false will hide the label and the field in panels and tables.
numSelectionCharacters   Number of characters used to search matching entries of the combobox. It is used to select by typing the first characters.
editable true
false
Set true will make the box editable
width int value The width of the combobox in pixels.
height int value The height of the combobox in pixels.
E1
.
En
  Textelements to be shown in the ComboBox
* = property you have to set; bold = default value

Version:
%I%, %G%
Author:
H.Pfohl

Field Summary
 
Fields inherited from class com.cbse.jeasy.JEObject
DEVELOPPING, INPUT_ERROR_DATE, INPUT_ERROR_LENGTH, INPUT_ERROR_MANDATORY, INPUT_ERROR_PARSE, INPUT_ERROR_RANGE, INPUT_ERROR_TIME, INPUT_ERRORS, NO_INPUT_ERROR, RUNNING
 
Constructor Summary
JEComboBox(java.lang.String s)
          Reads the properties from a string
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 void addItem(java.lang.String text)
          Add an item to the combobox
 void addItemAndValue(java.lang.String text, java.lang.Object value)
          Add an item to the combobox and an corresponding value
 void backupEntry()
          The current selected item will be stored internal to check against changes
 void clear()
          Selection of the first item
 void disableListeners()
          Removes the ItemListener and ActionListener
 void enableListeners()
          Adds the ItemListener and ActionListener after a previous disableListeners()
 int examine()
          Checks if an entry is mandatoy
 void focusGained(java.awt.event.FocusEvent fe)
           
 void focusLost(java.awt.event.FocusEvent fe)
           
 boolean getAntialiasing()
          Gets the anialialising flag
 java.awt.Color getBackground()
           
 java.lang.String getBackupEntry()
          Gets the backuped selected item
 javax.swing.border.Border getBorder()
          Get the border
 javax.swing.JComboBox getComboBox()
          Gets the jfc-Component JCombobox
 javax.swing.JComponent getComponent()
          Gets the JComponent based on this JEasy Object
 java.lang.String getElementAt(int n)
          Gets the textelement of index n in the origin XML
 int getElementSize()
          Gets the number of textelements defined in the origin XML
 javax.swing.plaf.ColorUIResource getErrorBackground()
           
 java.lang.Integer getIndexByValue(java.lang.Object value)
          Gets the index by the value that was added with addItemAndValue
 java.lang.Object getItemAt(int n)
          Gets the textelement of index n JCombobox
 java.lang.Object getItemByValue(java.lang.Object o)
          Gets the item that was added with this value by addItemAndValue
 int getItemCount()
          Gets the number of entries in the JCombobox
 java.lang.Class getJClass()
          Get the JClass
 javax.swing.JLabel getJLabel()
          Get the JLabel
 java.awt.GridBagConstraints getLabelConstraints()
          Gets the LabelConstraints (i.e. global.labelConstraints)
 java.awt.Font getLabelFont()
          Gets the font of the label (i.e. global.labelFont)
 boolean getMarkingBackground()
           
 java.lang.String getName()
          Gets the name of the label
 int getNumSelectionCharacters()
          Gets the number of characters used to select an item bei keystroke.
 java.lang.String getSelectedItem()
          Gets the selected item Same as getText()
 java.lang.String getText()
          Gets the selected item
 java.awt.GridBagConstraints getTextFieldConstraints()
          Gets the TextFieldConstraints (i.e. global.textfieldConstraints)
 java.awt.Font getTextFieldFont()
          Gets the font of the textelements (i.e. global.textFieldFont)
 java.lang.Object getValue()
          Gets the value of the selected item.
 java.lang.Object getValueAt(int n)
          Gets the value of index n JCombobox
 java.lang.String getXMLtag()
          Gets the XMLtag.
 java.lang.String getXMLValuetag()
          Gets the XMLValuetag.
 boolean isEditable()
          True if the combobox can be edited
 boolean isEnabled()
          False if the state of the ComboBox should not be changed in a Table or Panel
 boolean isListenEnabled()
          True if Listeners are enabled
 boolean isMandatory()
          Return if an entry is mandatory
 boolean isVisible()
          False if the ComboBox should not be shown in a Table or Panel
 void itemStateChanged(java.awt.event.ItemEvent e)
           
 void JEadd(java.awt.Container co, java.awt.LayoutManager lm)
          Adds the JLabel the JComboBox and the JButton when it is set to true to the Container.
 void JEadd(java.lang.String border, java.awt.Container co)
          Adds the Components to a Container with a BorderLayout
 void keyPressed(java.awt.event.KeyEvent e)
           
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
           
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void remove()
          Removes all entries
 void restoreEntry()
          Selects the item that was backuped before
 void setBackground(java.awt.Color c)
          Sets the background of the combobox
 void setBackground(java.lang.String jeasyColor)
           
 void setEditable(boolean b)
          setEditable of the combobox
 void setEnabled(boolean eb)
          Enables/disables the combobox and the button
 boolean setFocus()
          Sets the focus
 void setMandatory(boolean b)
          Sets the entry mandatory or not
 boolean setMatchingItem(java.lang.String s)
          Select item that begins with the given String and return true or return false if no item matches If the given string is empty the item of index 0 is selected and true is returned
 void setNumSelectionCharacters(int i)
          Sets the number of characters used to select an item bei keystroke.
 void setRemoveOnClear(boolean b)
          Set to true will remove all items on clear()
 void setSelectedIndex(int i)
          Select index
 void setSelectedItem(java.lang.Object o)
          Set the selected item to o.
 void setSelectedItem(java.lang.Object o, java.lang.String value)
          Set the selected item and value.
 void setSelectedItemByValue(java.lang.Object o)
          Set the selected item to the given vaule added ba addItemAndValue(...)
 void setText(java.lang.String text)
          Sets the selected item to text
 void setVisible(boolean bv)
          setVisible of the combobox
 void setXMLtag(java.lang.String s)
          Sets the XMLtag
 void setXMLValuetag(java.lang.String s)
          Sets the XMLValuetag
 void start()
          Creates jfc-Objects with the given properties.
 void transferFocus()
          transfers the focus to the next field
 void transferFocusBackward()
          transfers the focus to the previuos field
 boolean wasEntryChanged()
          The components compares the current entry with the data stored by backupEntry()
 
Methods inherited from class com.cbse.jeasy.JEObject
deserializeValue, getApplet, getApplLocale, getCenter, getEast, getId, getJCallBack, getLabel, getMode, getNorth, getObjLocale, getParentId, getPreview, getProjectDirectory, getProperty, getRegisterText, getSouth, getStarted, getTitle, getType, getWest, isEnterprise, isProfessional, isStandard, JEadd, JEadd, JEadd, JEadd, JEadd, JEadd, JEadd, JEadd, JEadd, JEaddTab, removeProperties, removeProperty, serializeValue, setApplet, setApplLocale, setEditable, setEnabled, setJCallBack, setMarkable, setMarkable, setMode, setObjLocale, setParentId, setPreview, setProjectDirectory, setProperty, setStarted, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JEComboBox

public JEComboBox(java.lang.String s)
Reads the properties from a string

Parameters:
s - contains properties and values
See Also:
JE#PropertyString
Method Detail

getElementSize

public int getElementSize()
Gets the number of textelements defined in the origin XML

Overrides:
getElementSize in class JEObject
Returns:
int

setMandatory

public void setMandatory(boolean b)
Sets the entry mandatory or not


isMandatory

public boolean isMandatory()
Return if an entry is mandatory


getBackground

public java.awt.Color getBackground()

setBackground

public void setBackground(java.lang.String jeasyColor)

getJLabel

public javax.swing.JLabel getJLabel()
Get the JLabel

Returns:
JLabel

setBackground

public void setBackground(java.awt.Color c)
Sets the background of the combobox


getErrorBackground

public javax.swing.plaf.ColorUIResource getErrorBackground()

getBorder

public javax.swing.border.Border getBorder()
Get the border

Returns:
Border

getElementAt

public java.lang.String getElementAt(int n)
Gets the textelement of index n in the origin XML

Overrides:
getElementAt in class JEObject
Parameters:
n - index beginning by zero
Returns:
String

getItemAt

public java.lang.Object getItemAt(int n)
Gets the textelement of index n JCombobox

Parameters:
n - index beginning by zero
Returns:
String

getItemByValue

public java.lang.Object getItemByValue(java.lang.Object o)
Gets the item that was added with this value by addItemAndValue

Returns:
Object

getIndexByValue

public java.lang.Integer getIndexByValue(java.lang.Object value)
Gets the index by the value that was added with addItemAndValue

Returns:
Integer index or null if no entry for this value

getValueAt

public java.lang.Object getValueAt(int n)
Gets the value of index n JCombobox

Parameters:
n - index beginning by zero
Returns:
Object

getItemCount

public int getItemCount()
Gets the number of entries in the JCombobox

Returns:
number

getName

public java.lang.String getName()
Gets the name of the label

Overrides:
getName in class JEObject
Returns:
String

getNumSelectionCharacters

public int getNumSelectionCharacters()
Gets the number of characters used to select an item bei keystroke. Default is one in Swing

Returns:
int

setNumSelectionCharacters

public void setNumSelectionCharacters(int i)
Sets the number of characters used to select an item bei keystroke. Default is one in Swing


getXMLtag

public java.lang.String getXMLtag()
Gets the XMLtag. Returns the id if no XMLtag is specified

Overrides:
getXMLtag in class JEObject
Returns:
String

setXMLtag

public void setXMLtag(java.lang.String s)
Sets the XMLtag


getXMLValuetag

public java.lang.String getXMLValuetag()
Gets the XMLValuetag. Returns the id if no XMLValuetag is specified

Returns:
String

setXMLValuetag

public void setXMLValuetag(java.lang.String s)
Sets the XMLValuetag


getComponent

public javax.swing.JComponent getComponent()
Gets the JComponent based on this JEasy Object

Overrides:
getComponent in class JEObject
Returns:
JComponent

disableListeners

public void disableListeners()
Removes the ItemListener and ActionListener


enableListeners

public void enableListeners()
Adds the ItemListener and ActionListener after a previous disableListeners()


isListenEnabled

public boolean isListenEnabled()
True if Listeners are enabled


getComboBox

public javax.swing.JComboBox getComboBox()
Gets the jfc-Component JCombobox

Returns:
JComboBox

getJClass

public java.lang.Class getJClass()
Get the JClass

Overrides:
getJClass in class JEObject
Returns:

getMarkingBackground

public boolean getMarkingBackground()

getText

public java.lang.String getText()
Gets the selected item

Returns:
Textelement of the ComboBox

getSelectedItem

public java.lang.String getSelectedItem()
Gets the selected item Same as getText()

Returns:
Textelement of the ComboBox

getValue

public java.lang.Object getValue()
Gets the value of the selected item.

Returns:
value of the selected Textelement of the ComboBox

setText

public void setText(java.lang.String text)
Sets the selected item to text

Parameters:
text - the string to be set

setFocus

public boolean setFocus()
Sets the focus

Overrides:
setFocus in class JEObject

setRemoveOnClear

public void setRemoveOnClear(boolean b)
Set to true will remove all items on clear()

Parameters:
boolean -

addItem

public void addItem(java.lang.String text)
Add an item to the combobox

Parameters:
the - string to be set

addItemAndValue

public void addItemAndValue(java.lang.String text,
                            java.lang.Object value)
Add an item to the combobox and an corresponding value

Parameters:
text - the string to be set
value - the value you can give this entry. Get it by getValue

setEnabled

public void setEnabled(boolean eb)
Enables/disables the combobox and the button

Overrides:
setEnabled in class JEObject

setVisible

public void setVisible(boolean bv)
setVisible of the combobox

Overrides:
setVisible in class JEObject

isVisible

public boolean isVisible()
False if the ComboBox should not be shown in a Table or Panel

Overrides:
isVisible in class JEObject
Returns:
visible

isEnabled

public boolean isEnabled()
False if the state of the ComboBox should not be changed in a Table or Panel

Overrides:
isEnabled in class JEObject
Returns:
enabled

isEditable

public boolean isEditable()
True if the combobox can be edited

Overrides:
isEditable in class JEObject
Returns:
editable

setEditable

public void setEditable(boolean b)
setEditable of the combobox

Overrides:
setEditable in class JEObject

setSelectedItem

public void setSelectedItem(java.lang.Object o)
Set the selected item to o. If there is no entry found like o this item is added and selected


setSelectedItem

public void setSelectedItem(java.lang.Object o,
                            java.lang.String value)
Set the selected item and value. If there is no entry found like o this item is added and selected


setSelectedItemByValue

public void setSelectedItemByValue(java.lang.Object o)
Set the selected item to the given vaule added ba addItemAndValue(...)


setSelectedIndex

public void setSelectedIndex(int i)
Select index


setMatchingItem

public boolean setMatchingItem(java.lang.String s)
Select item that begins with the given String and return true or return false if no item matches If the given string is empty the item of index 0 is selected and true is returned

Returns:
true item matches

clear

public void clear()
Selection of the first item

Overrides:
clear in class JEObject

remove

public void remove()
Removes all entries


backupEntry

public void backupEntry()
The current selected item will be stored internal to check against changes

Overrides:
backupEntry in class JEObject

getBackupEntry

public java.lang.String getBackupEntry()
Gets the backuped selected item

Returns:
String

restoreEntry

public void restoreEntry()
Selects the item that was backuped before

Overrides:
restoreEntry in class JEObject

examine

public int examine()
Checks if an entry is mandatoy

Returns:
0 if an entry is set or mandatory is false else JEObject.INPUT_ERROR_MANDATORY

wasEntryChanged

public boolean wasEntryChanged()
The components compares the current entry with the data stored by backupEntry()

Overrides:
wasEntryChanged in class JEObject
Returns:
true data was changed false current data is equal backup data

getAntialiasing

public boolean getAntialiasing()
Gets the anialialising flag


getLabelFont

public java.awt.Font getLabelFont()
Gets the font of the label (i.e. global.labelFont)

Returns:
the font of the label

getTextFieldFont

public java.awt.Font getTextFieldFont()
Gets the font of the textelements (i.e. global.textFieldFont)

Returns:
the font of the textfield

getLabelConstraints

public java.awt.GridBagConstraints getLabelConstraints()
Gets the LabelConstraints (i.e. global.labelConstraints)

Returns:
GridBagConstraints

getTextFieldConstraints

public java.awt.GridBagConstraints getTextFieldConstraints()
Gets the TextFieldConstraints (i.e. global.textfieldConstraints)

Returns:
GridBagConstraints

transferFocus

public void transferFocus()
transfers the focus to the next field


transferFocusBackward

public void transferFocusBackward()
transfers the focus to the previuos field


start

public void start()
Creates jfc-Objects with the given properties. The font of the label is set to global.labelFont. The font of the TextField is set to global.textFieldFont. The elements are added as items to the ComboBox

Overrides:
start in class JEObject

JEadd

public void JEadd(java.awt.Container co,
                  java.awt.LayoutManager lm)
Adds the JLabel the JComboBox and the JButton when it is set to true to the Container. Uses the constraints when the LayoutManager is a GridBagLayout.

Overrides:
JEadd in class JEObject
Parameters:
Container - where the Components are added

JEadd

public void JEadd(java.lang.String border,
                  java.awt.Container co)
Adds the Components to a Container with a BorderLayout

Overrides:
JEadd in class JEObject
Parameters:
String - "North" "South" "West" "East" "Center"
Container - where the Components are added

focusGained

public void focusGained(java.awt.event.FocusEvent fe)
Specified by:
focusGained in interface java.awt.event.FocusListener

focusLost

public void focusLost(java.awt.event.FocusEvent fe)
Specified by:
focusLost in interface java.awt.event.FocusListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Specified by:
keyTyped in interface java.awt.event.KeyListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent e)
Specified by:
itemStateChanged in interface java.awt.event.ItemListener

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener