net.lenkaspace.creeper.view
Class CRComponentFactory

java.lang.Object
  extended by net.lenkaspace.creeper.view.CRComponentFactory

public class CRComponentFactory
extends java.lang.Object

Provides static functions for creating components. Use e.g. by CRControlPanel

Version:
2.0
Author:
Lenka Pitonakova contact@lenkaspace.net

Constructor Summary
CRComponentFactory()
           
 
Method Summary
static javax.swing.JPanel createDividerJPanel(int width_, int spaceAround_, java.awt.Container parent_)
          Create a horizontal line to divide components
static javax.swing.JPanel createFlowLayoutJPanel(int width_, int height_, java.awt.Container parent_)
          Create a JPanel with FlowLayout.LEFT and optionally add it to a Container
static javax.swing.JButton createJButton(java.lang.String buttonText_, java.awt.event.ActionListener actionListener_, java.awt.Container parent_)
          Create a JButton that will resize with text and optionally add it to a Container
static javax.swing.JCheckBox createJCheckBox(java.lang.String text_, boolean isSelected_, java.awt.event.ActionListener actionListener_, java.awt.Container parent_)
          Create a JCheckBox and optionally add it to a Container
static javax.swing.JComboBox createJComboBox(int width_, java.lang.String[] items_, int selectedIndex_, java.awt.event.ActionListener actionListener_, java.awt.Container parent_)
          Create a JComboBox and optionally add it to a Container
static javax.swing.JLabel createJLabel(java.lang.String text_, java.awt.Container parent_)
          Create a JLabel and optionally add it to a Container
static javax.swing.JSlider createJSlider(int width_, int min_, int max_, int value_, javax.swing.event.ChangeListener changeListener_, java.awt.Container parent_)
          Create a JSlider and optionally add it to a Container
static javax.swing.JTextField createJTextField(java.lang.String defaultVal_, int width_, java.awt.Container parent_)
          Create JTextField
static javax.swing.JTextPane createJTextPane(java.lang.String text_, int width_, int height_, java.awt.Container parent_)
          Create a JTextPane (multiline output text) and optionally add it to a container
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CRComponentFactory

public CRComponentFactory()
Method Detail

createJButton

public static javax.swing.JButton createJButton(java.lang.String buttonText_,
                                                java.awt.event.ActionListener actionListener_,
                                                java.awt.Container parent_)
Create a JButton that will resize with text and optionally add it to a Container

Parameters:
buttonText_ - String text of the button
actionListener_ - ActionListener action listener. Can be null.
parent_ - Container instance to add the new component to. Can be null.
Returns:
JButton the button

createJTextField

public static javax.swing.JTextField createJTextField(java.lang.String defaultVal_,
                                                      int width_,
                                                      java.awt.Container parent_)
Create JTextField

Parameters:
defaultVal_ - String default value of the text field
width_ - int width
parent_ - Container instance to add the new component to. Can be null.
Returns:
JTextField text field

createJCheckBox

public static javax.swing.JCheckBox createJCheckBox(java.lang.String text_,
                                                    boolean isSelected_,
                                                    java.awt.event.ActionListener actionListener_,
                                                    java.awt.Container parent_)
Create a JCheckBox and optionally add it to a Container

Parameters:
text_ - String text to the check box
isSelected_ - boolean set true to pre-select
actionListener_ - ActionListener action listener. Can be null.
parent_ - Container instance to add the new component to. Can be null.
Returns:
JCheckBox check box

createJSlider

public static javax.swing.JSlider createJSlider(int width_,
                                                int min_,
                                                int max_,
                                                int value_,
                                                javax.swing.event.ChangeListener changeListener_,
                                                java.awt.Container parent_)
Create a JSlider and optionally add it to a Container

Parameters:
width_ - int width of the panel. Set to < 0 to set the width according to the width of the parent Container
min_ - int minimum value
max_ - int maximum value
value_ - int default value
changeListener_ - ChangeListener listener object. Can be null.
parent_ - Container instance to add the new component to. Can be null.
Returns:
JSlider slider

createJComboBox

public static javax.swing.JComboBox createJComboBox(int width_,
                                                    java.lang.String[] items_,
                                                    int selectedIndex_,
                                                    java.awt.event.ActionListener actionListener_,
                                                    java.awt.Container parent_)
Create a JComboBox and optionally add it to a Container

Parameters:
width_ - int width of the panel. Set to < 0 to set the width according to the width of the parent Container
items_ - String[] items in the combo box
selectedIndex_ - int preselected item index
actionListener_ - ActionListener action listener. Can be null.
parent_ - Container instance to add the new component to. Can be null.
Returns:
JComboBox combo box

createJLabel

public static javax.swing.JLabel createJLabel(java.lang.String text_,
                                              java.awt.Container parent_)
Create a JLabel and optionally add it to a Container

Parameters:
text_ - String text for the label
parent_ - Container instance to add the new component to. Can be null.
Returns:
JLabel label

createJTextPane

public static javax.swing.JTextPane createJTextPane(java.lang.String text_,
                                                    int width_,
                                                    int height_,
                                                    java.awt.Container parent_)
Create a JTextPane (multiline output text) and optionally add it to a container

Parameters:
text_ - String text
width_ - int width of the panel. Set to < 0 to set the width according to the width of the parent Container
height_ - int height of the panel. Set to < 0 to set the width according to the height of the parent Container
parent_ - Container instance to add the new component to. Can be null.
Returns:
JTextPane jTextPane

createFlowLayoutJPanel

public static javax.swing.JPanel createFlowLayoutJPanel(int width_,
                                                        int height_,
                                                        java.awt.Container parent_)
Create a JPanel with FlowLayout.LEFT and optionally add it to a Container

Parameters:
width_ - int width of the panel. Set to < 0 to set the width according to the width of the parent Container
height_ - int height of the panel
parent_ - Container instance to add the new component to. Can be null.
Returns:
JPanel panel

createDividerJPanel

public static javax.swing.JPanel createDividerJPanel(int width_,
                                                     int spaceAround_,
                                                     java.awt.Container parent_)
Create a horizontal line to divide components

Parameters:
width_ - int width of the panel. Set to < 0 to set the width according to the width of the parent Container
spaceAround_ - space above and under the line
parent_ - Container instance to add the new component to. Can be null.
Returns:
JPanel divider panel