|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
eu.beesoft.gaia.swing.SimpleSwingForm
public class SimpleSwingForm
SimpleSwingForm is a component designed to the simplification of building the Swing forms.
customizeLabelConstraints(GridBagConstraints, JLabel)
and
customizeComponentConstraints(GridBagConstraints, JComponent)
okActionPerformed()
method without writting any actionHere is a simple example of SimpleSwingForm usage:
SimpleSwingForm form = new SimpleSwingForm (); form.addLabeledComponent ("Label 1", form.createTextField ()); form.addLabeledComponent ("Label 2", new JTextArea ()); Action okAction = new MyOkAction (); // you must do something on OK form.showDialog ("My form", okAction, form.createStandardCancelAction ());
This builds on the 5 lines of code a two-rows form with labels "Label 1" and "Label 2" in the first column and components text field and text area in the second. Then is the form displayed in a dialog.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
javax.swing.JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary |
---|
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
SimpleSwingForm()
Create a new instance of the SimpleSwingForm. |
Method Summary | |
---|---|
void |
addComponent(javax.swing.JComponent component)
Adds component to this form. |
void |
addComponent(javax.swing.JComponent component,
int width,
int height)
Adds component to this form. |
void |
addFiller()
Adds filler as last component in the form. |
javax.swing.JLabel |
addLabel(java.lang.String label)
Creates a new JLabel component for given label text and adds
it to this form. |
javax.swing.JLabel |
addLabeledComponent(java.lang.String label,
javax.swing.JComponent component)
Adds component and its label to this form. |
javax.swing.JLabel |
addLabeledComponent(java.lang.String label,
javax.swing.JComponent component,
int width,
int height)
Adds component and its label to this form. |
protected void |
cancelActionPerformed()
Invoked when user press standard Cancel action. |
javax.swing.Action |
createStandardCancelAction()
Creates Action for Cancel button. |
javax.swing.Action |
createStandardOkAction()
Creates Action for OK button. |
javax.swing.JTextArea |
createTextArea()
Creates a new text area with processed minimum size and sets the font from JLabel as its font. |
javax.swing.JTextArea |
createTextArea(int rows)
Creates a new text area with processed minimum size and sets the font from JLabel as its font. |
javax.swing.JTextField |
createTextField()
Creates a new text field with processed minimum size. |
javax.swing.JTextField |
createTextField(int columns)
Creates a new text field with processed minimum size. |
protected void |
customizeComponentConstraints(java.awt.GridBagConstraints gbc,
javax.swing.JComponent component)
Customizes GridBagConstraints object for the component. |
protected void |
customizeLabelConstraints(java.awt.GridBagConstraints gbc,
javax.swing.JLabel label)
Customizes GridBagConstraints object for label. |
void |
destroyDialog()
Removes dialog in which is displayed this form and disposes it. |
java.awt.GridBagConstraints |
getConstraints()
Returns the constraints object used by this SimpleSwingForm. |
static javax.swing.Icon |
getIcon(java.lang.String name)
Builds and returns an ImageIcon for given name . |
protected void |
okActionPerformed()
Invoked when user press standard OK action. |
void |
showDialog(javax.swing.JDialog owner,
java.lang.String title,
javax.swing.Action... actions)
Displays this form in the dialog. |
void |
showDialog(javax.swing.JDialog owner,
java.lang.String title,
javax.swing.JButton... buttons)
Displays this form in the dialog. |
void |
showDialog(javax.swing.JFrame owner,
java.lang.String title,
javax.swing.Action... actions)
Displays this form in the dialog. |
void |
showDialog(javax.swing.JFrame owner,
java.lang.String title,
javax.swing.JButton... buttons)
Displays this form in the dialog. |
void |
showDialog(java.lang.String title,
javax.swing.Action... actions)
Displays this form in the dialog. |
void |
showDialog(java.lang.String title,
javax.swing.JButton... buttons)
Displays this form in the dialog. |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintComponent, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printComponent, printChildren, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, checkImage, checkImage, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SimpleSwingForm()
Method Detail |
---|
public java.awt.GridBagConstraints getConstraints()
public javax.swing.JLabel addLabeledComponent(java.lang.String label, javax.swing.JComponent component)
label
- - a label text usually displayed in front of component, can be
nullcomponent
- - component to add
public javax.swing.JLabel addLabeledComponent(java.lang.String label, javax.swing.JComponent component, int width, int height)
label
- - a label text usually displayed in front of component, can be
nullcomponent
- - component to addwidth
- - specifies the number of cells in a row for the component's
display area.height
- - specifies the number of cells in a column for the
component's display area.
public javax.swing.JLabel addLabel(java.lang.String label)
label
text and adds
it to this form.
label
- - a label text
protected void customizeLabelConstraints(java.awt.GridBagConstraints gbc, javax.swing.JLabel label)
gbc
- - a constraintslabel
- - a JLabel componentpublic void addComponent(javax.swing.JComponent component)
component
- - a component to addpublic void addComponent(javax.swing.JComponent component, int width, int height)
component
- - a component to addwidth
- - specifies the number of cells in a row for the component's
display area.height
- - specifies the number of cells in a column for the
component's display area.protected void customizeComponentConstraints(java.awt.GridBagConstraints gbc, javax.swing.JComponent component)
JDateField
JTextField
with defined columns
number
gbc
- - a constraintscomponent
- - a componentpublic void addFiller()
public void showDialog(java.lang.String title, javax.swing.Action... actions)
title
- - the dialog titleactions
- - the actions to control dialogpublic void showDialog(javax.swing.JFrame owner, java.lang.String title, javax.swing.Action... actions)
owner
- - the Frame from which the dialog is displayedtitle
- - the dialog titleactions
- - the actions to control dialogpublic void showDialog(javax.swing.JDialog owner, java.lang.String title, javax.swing.Action... actions)
owner
- - the Dialog from which the new dialog is displayedtitle
- - the dialog titleactions
- - the actions to control dialogpublic void showDialog(java.lang.String title, javax.swing.JButton... buttons)
title
- - the dialog titlebuttons
- - the buttons to control dialogpublic void showDialog(javax.swing.JDialog owner, java.lang.String title, javax.swing.JButton... buttons)
owner
- - the Dialog from which the new dialog is displayedtitle
- - the dialog titlebuttons
- - the buttons to control dialogpublic void showDialog(javax.swing.JFrame owner, java.lang.String title, javax.swing.JButton... buttons)
owner
- - the Frame from which the dialog is displayedtitle
- - the dialog titlebuttons
- - the buttons to control dialogpublic void destroyDialog()
protected void okActionPerformed()
OK
action. Simply calls
destroyDialog()
in this implementation.
protected void cancelActionPerformed()
Cancel
action. Simply calls
destroyDialog()
in this implementation.
public javax.swing.Action createStandardOkAction()
OK
button. When this action is invoked,
it calls okActionPerformed()
method to process the event.
public javax.swing.Action createStandardCancelAction()
Cancel
button. When this action is
invoked, it calls cancelActionPerformed()
method to process the
event.
public javax.swing.JTextField createTextField()
public javax.swing.JTextField createTextField(int columns)
columns
- - the number of columns to use to calculate the preferred
width; if columns is set to zero, the preferred width will be
whatever naturally results from the component implementation
public javax.swing.JTextArea createTextArea()
public javax.swing.JTextArea createTextArea(int rows)
rows
- - the number of rows >= 0
public static javax.swing.Icon getIcon(java.lang.String name)
name
. The name is
a resource name on the classpath.
name
- - icon name (or file name) on classpath
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |