public class Setup
extends javax.swing.JDialog
implements SetupItem.SetupItemListener, java.awt.event.ActionListener
A setup dialog is used to load parameters for an application and to present the parameters in a UI that pops up before the application launches. The user is given the opportunity to change setup parameters as appropriate for the current launch of the application. Changes to parameters may be saved and used as default values for the next launch.
Five classes are defined herein: Setup
, SetupItem
, SetupItemInfo
,
SetupEvent
, Configuration
. There is also a listener named SetupItemListener
defined in SetupItem
.
The motivation for the Setup
class is to provide a single, consistent setup mechanism for use across
different experimental applications. Examples are seen in the APIs for GraffitiExperiment, H4WriterExperiment,
LetterGuessingExperiment, PhoneKeypadExperiment, SAKExperiment, SoftKeyboardExperiment, and TypingTestExperiment.
Below is the setup dialog from SoftKeyboardExperiment: (click to enlarge)
There are five types of setup items that can be combined in designing a setup dialog:
JLabel
(left) and a JComboBox
(right), for example
JLabel
(left) and a JTextField
(right), for
example
JCheckBox
(left) and a JLabel
(right), for example
JRadioButton
objects forming a
ButtonGroup
, for example
JLabel
(left) and a JButton
with the text
"Browse...", for example
Setup
class extends JDialog
:
public class Setup extends JDialog implements SetupItem.SetupItemListener, ActionListener { ... Setup(Frame owner, Configuration cArg, String appNameArg, SetupItemInfo[] itemInfoArg) { ...The constructor requires four arguments: (i) the owner (use
null
), (ii) an instance of
Configuration
defining the initial configuration parameters, (iii) the application's name as a string,
and (iv) an array of SetupItemInfo
objects.
For specific coding details on using Setup
, consult the source code for one of the example applications
(e.g., SAKExperiment.java
).
Note: The example applications do not include a setup parameter for "Block". The block code is generated automatically in the application software. Consult the application source code for details.
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Constructor and Description |
---|
Setup(java.awt.Frame owner,
Configuration cArg,
java.lang.String appNameArg,
SetupItemInfo[] itemInfoArg)
Setup - a UI for presenting and changing parameters that set the operation of an application.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent ae) |
void |
onSetupItemChanged(SetupEvent e) |
boolean |
showSetup(java.awt.Frame f) |
getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setTransferHandler, update
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, setVisible, show, toBack
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, toFront
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public Setup(java.awt.Frame owner, Configuration cArg, java.lang.String appNameArg, SetupItemInfo[] itemInfoArg)
owner
- nullcArg
- a Configuration
object holding the initial parameter values for the setup dialogappNameArg
- a String
holding the name of the applicationitemInfoArg
- an array of SetupItemInfo
objects that define the entries in the setup dialogpublic void actionPerformed(java.awt.event.ActionEvent ae)
actionPerformed
in interface java.awt.event.ActionListener
public void onSetupItemChanged(SetupEvent e)
onSetupItemChanged
in interface SetupItem.SetupItemListener
public boolean showSetup(java.awt.Frame f)