NOS.gui
Class NOSButton

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by NOS.gui.NOSButton
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, NOSStyleListener

public class NOSButton
extends javax.swing.JComponent
implements NOSStyleListener

See Also:
Serialized Form

Nested Class Summary
 
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.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  boolean border
           
protected  int custom_icon_height
           
protected  int[] custom_icon_pix
           
protected  int custom_icon_width
           
protected  java.awt.Image focus
           
protected  boolean hover
           
protected  int icon
           
protected  java.lang.String label
           
protected  java.awt.Image pressed
           
protected  Style style
           
protected  java.awt.Image unfocus
           
 
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
NOSButton(java.awt.image.BufferedImage buf, boolean border)
          Creates a new NOSButton object.
NOSButton(int icon, boolean border)
          Creates a new NOSButton object.
NOSButton(java.lang.String label)
          Creates a new NOSButton object.
NOSButton(java.lang.String label, boolean border)
          Creates a new NOSButton object.
NOSButton(java.lang.String label, int icon, boolean toggle, boolean border, java.awt.image.BufferedImage buf)
          Creates a new NOSButton object.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener al)
          Adds an ActionListener to this button
 int getIcon()
          Returns the system icon to be drawn on this button.
 java.lang.String getLabel()
          Returns the label text of this button
 java.awt.Dimension getMinimumSize()
          Returns the minimum size of this button
 java.awt.Dimension getPreferredSize()
          Returns the preferred size of this button
 boolean isToggle()
          Returns the toggle behaviour of this button
 void notifyActionListeners()
          Calls all the action listeners attached to this button.
 void notifyStyleChange(Style style)
          Called by the system to notify this button that the active Style has been changed.
 void paint(java.awt.Graphics g)
          Draw this component.
 void removeActionListener(java.awt.event.ActionListener al)
          Removes an ActionListener from this button
 void setHoverEnable(boolean hover)
          Set the hover behaviour of this button
 void setIcon(int icon)
          Changes the system icon displayed on this button
 void setLabel(java.lang.String label)
          Changes the label displayed on this button
 void setToggle(boolean press)
          Changes the toggle behaviour of this button
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, 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, updateUI
 
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, checkImage, checkImage, 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, 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
 

Field Detail

custom_icon_pix

protected int[] custom_icon_pix

custom_icon_width

protected int custom_icon_width

custom_icon_height

protected int custom_icon_height

icon

protected int icon

label

protected java.lang.String label

border

protected boolean border

style

protected Style style

focus

protected java.awt.Image focus

unfocus

protected java.awt.Image unfocus

pressed

protected java.awt.Image pressed

hover

protected boolean hover
Constructor Detail

NOSButton

public NOSButton(java.lang.String label)
Creates a new NOSButton object.

Parameters:
label - A string label to display on the button.

NOSButton

public NOSButton(java.awt.image.BufferedImage buf,
                 boolean border)
Creates a new NOSButton object.

Parameters:
buf - An image to display on the button
border - Set to true if you want a border to be drawn around the button

NOSButton

public NOSButton(java.lang.String label,
                 boolean border)
Creates a new NOSButton object.

Parameters:
label - A string label to display on the button.
border - Set to true if you want a border to be drawn around the button

NOSButton

public NOSButton(int icon,
                 boolean border)
Creates a new NOSButton object.

Parameters:
icon - The system icon to be drawn on the button (eg: one of Style.ICON_CLOSE, Style.ICON_MAXIMISE, Style.ICON_RESTORE, Style.ICON_MINIMISE, .. etc ..)
border - Set to true if you want a border to be drawn around the button

NOSButton

public NOSButton(java.lang.String label,
                 int icon,
                 boolean toggle,
                 boolean border,
                 java.awt.image.BufferedImage buf)
Creates a new NOSButton object.

Parameters:
label - A string label to display on the button.
icon - The system icon to be drawn on the button (eg: one of Style.ICON_CLOSE, Style.ICON_MAXIMISE, Style.ICON_RESTORE, Style.ICON_MINIMISE, .. etc ..)
toggle - If set to true this button will act like a toggle switch.
border - Set to true if you want a border to be drawn around the button
buf - An image to display on the button (is overriden by icon if not set to Style.ICON_NONE)
Method Detail

setHoverEnable

public void setHoverEnable(boolean hover)
Set the hover behaviour of this button

Parameters:
hover - If true then the button will animate when the user hovers the mouse over it.

notifyStyleChange

public void notifyStyleChange(Style style)
Called by the system to notify this button that the active Style has been changed.

Specified by:
notifyStyleChange in interface NOSStyleListener
Parameters:
style - The new Style object.

setLabel

public void setLabel(java.lang.String label)
Changes the label displayed on this button

Parameters:
label - The new label

getLabel

public java.lang.String getLabel()
Returns the label text of this button

Returns:
The label.

setIcon

public void setIcon(int icon)
Changes the system icon displayed on this button

Parameters:
icon - The system icon to be drawn on the button (eg: one of Style.ICON_CLOSE, Style.ICON_MAXIMISE, Style.ICON_RESTORE, Style.ICON_MINIMISE, .. etc ..)

getIcon

public int getIcon()
Returns the system icon to be drawn on this button.

Returns:
The system icon to be drawn on the button (eg: one of Style.ICON_CLOSE, Style.ICON_MAXIMISE, Style.ICON_RESTORE, Style.ICON_MINIMISE, .. etc ..)

addActionListener

public void addActionListener(java.awt.event.ActionListener al)
Adds an ActionListener to this button

Parameters:
al - The ActionListener to be added.

removeActionListener

public void removeActionListener(java.awt.event.ActionListener al)
Removes an ActionListener from this button

Parameters:
al - The ActionListener to be removed.

notifyActionListeners

public void notifyActionListeners()
Calls all the action listeners attached to this button.


paint

public void paint(java.awt.Graphics g)
Draw this component.

Overrides:
paint in class javax.swing.JComponent
Parameters:
g - The Graphics context to use.

setToggle

public void setToggle(boolean press)
Changes the toggle behaviour of this button

Parameters:
press - If true then this button will act like a toggle switch.

isToggle

public boolean isToggle()
Returns the toggle behaviour of this button

Returns:
True indicates that this button will act like a toggle switch.

getMinimumSize

public java.awt.Dimension getMinimumSize()
Returns the minimum size of this button

Overrides:
getMinimumSize in class javax.swing.JComponent
Returns:
The minimum size.

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred size of this button

Overrides:
getPreferredSize in class javax.swing.JComponent
Returns:
The preferred size.