Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

jcurses.widgets
Class Button  view Button download Button.java

java.lang.Object
  extended byjcurses.widgets.Widget
      extended byjcurses.widgets.Button

public class Button
extends Widget

This class implements a buttton-widget. Such button has a label and is 'clicked' by user typing a special character (default 'enter'). If it is 'clicked', it generates an ActionEvent, that is delegetated to registered listeners.


Field Summary
private static jcurses.system.InputChar __actionChar
           
private static jcurses.system.CharColor __buttonDefaultColors
           
private static jcurses.system.CharColor __focusedButtonDefaultColors
           
private static jcurses.system.CharColor __shortCutDefaultColors
           
private  jcurses.system.CharColor _focusedButtonColors
           
private  java.lang.String _label
           
private  jcurses.event.ActionListenerManager _listenerManager
           
private  jcurses.system.InputChar _shortCut
           
private  jcurses.system.CharColor _shortCutColors
           
 
Fields inherited from class jcurses.widgets.Widget
_parent, _window
 
Constructor Summary
Button(java.lang.String label)
          The constructor
 
Method Summary
 void addListener(jcurses.event.ActionListener listener)
          Adds a listener to the button.
private  void changeColors()
           
private  void doAction()
           
protected  void doPaint()
          This method paints the widget.
protected  void doRepaint()
          This method repaints the widget.
private  void drawShortCutIfNeeded()
           
protected  void focus()
          The method is called bei setFocus to tell widget, thas it has get focus.
 jcurses.system.CharColor getDefaultColors()
           
 jcurses.system.CharColor getFocusedButtonColors()
           
private  jcurses.system.CharColor getFocusedButtonDefaultColors()
           
 java.lang.String getLabel()
           
protected  jcurses.util.Rectangle getPreferredSize()
          This method gives the widget container the infomation about the preferred size of this widget.
private  jcurses.system.InputChar getShortCut()
           
 jcurses.system.CharColor getShortCutColors()
           
private  jcurses.system.CharColor getShortCutDefaultColors()
           
protected  java.util.Vector getShortCutsList()
          This method returns a list of short cut chars, that the widget want to handle.
protected  boolean handleInput(jcurses.system.InputChar ch)
          The method is called by framework to let the widget handle an input char.
protected  boolean isFocusable()
          The method declares, whether the widget can handle input ( get focus ), that is, whether this is an input widget.
 void removeListener(jcurses.event.ActionListener listener)
          Removes a listener from the button.
 void setFocusedButtonColors(jcurses.system.CharColor colors)
          Sets button's colors in focused state
 void setLabel(java.lang.String label)
          Sets button's label
 void setShortCut(char c)
          Set's button's shortcut char.
 void setShortCutColors(jcurses.system.CharColor colors)
          Sets button's shortcut char's colors.
protected  void unfocus()
          The method is called bei setFocus to tell widget, thas it has lost focus.
 
Methods inherited from class jcurses.widgets.Widget
getAbsoluteX, getAbsoluteY, getColors, getFocus, getParent, getRectangle, getSize, getVisible, getWindow, getX, getY, hasFocus, isVisible, paint, repaint, setColors, setFocus, setParent, setSize, setVisible, setWindow, setX, setY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_listenerManager

private jcurses.event.ActionListenerManager _listenerManager

__buttonDefaultColors

private static jcurses.system.CharColor __buttonDefaultColors

_label

private java.lang.String _label

__focusedButtonDefaultColors

private static jcurses.system.CharColor __focusedButtonDefaultColors

_focusedButtonColors

private jcurses.system.CharColor _focusedButtonColors

__shortCutDefaultColors

private static jcurses.system.CharColor __shortCutDefaultColors

_shortCutColors

private jcurses.system.CharColor _shortCutColors

__actionChar

private static jcurses.system.InputChar __actionChar

_shortCut

private jcurses.system.InputChar _shortCut
Constructor Detail

Button

public Button(java.lang.String label)
The constructor

Method Detail

getDefaultColors

public jcurses.system.CharColor getDefaultColors()
Overrides:
getDefaultColors in class Widget

setLabel

public void setLabel(java.lang.String label)
Sets button's label


getLabel

public java.lang.String getLabel()

getFocusedButtonDefaultColors

private jcurses.system.CharColor getFocusedButtonDefaultColors()

getFocusedButtonColors

public jcurses.system.CharColor getFocusedButtonColors()

setFocusedButtonColors

public void setFocusedButtonColors(jcurses.system.CharColor colors)
Sets button's colors in focused state


getShortCutDefaultColors

private jcurses.system.CharColor getShortCutDefaultColors()

getShortCutColors

public jcurses.system.CharColor getShortCutColors()

setShortCutColors

public void setShortCutColors(jcurses.system.CharColor colors)
Sets button's shortcut char's colors. If the button has a shortcut char and this char is contained by the label, than the char within the label will be painted in different colors, set by this method


getPreferredSize

protected jcurses.util.Rectangle getPreferredSize()
Description copied from class: Widget
This method gives the widget container the infomation about the preferred size of this widget. Must be implemented by derived classes.

Specified by:
getPreferredSize in class Widget

doPaint

protected void doPaint()
Description copied from class: Widget
This method paints the widget. Will be called by paint(), only if the widget is visible. Must be implemented be derived classes.

Specified by:
doPaint in class Widget

drawShortCutIfNeeded

private void drawShortCutIfNeeded()

getShortCutsList

protected java.util.Vector getShortCutsList()
Description copied from class: Widget
This method returns a list of short cut chars, that the widget want to handle. If a char from the list is typed by user, it will be handled always my this widget not bei the widget currenty having focus, except the having focus widget handles ALL chars and tells this throuth the method handleAllPrintableChars. To enable shortcuts for a new widget, you must override this method.

Overrides:
getShortCutsList in class Widget

isFocusable

protected boolean isFocusable()
Description copied from class: Widget
The method declares, whether the widget can handle input ( get focus ), that is, whether this is an input widget.

Overrides:
isFocusable in class Widget

doRepaint

protected void doRepaint()
Description copied from class: Widget
This method repaints the widget. Will be called by paint(), only if the widget is visible. Must be implemented be derived classes.

Specified by:
doRepaint in class Widget

handleInput

protected boolean handleInput(jcurses.system.InputChar ch)
Description copied from class: Widget
The method is called by framework to let the widget handle an input char. Schould be overrided be derived classes, if these can handle input.

Overrides:
handleInput in class Widget

changeColors

private void changeColors()

focus

protected void focus()
Description copied from class: Widget
The method is called bei setFocus to tell widget, thas it has get focus. This method schold be overrided bei derived class to react getting focus, for examlple to repaint widget gettig focus.

Overrides:
focus in class Widget

unfocus

protected void unfocus()
Description copied from class: Widget
The method is called bei setFocus to tell widget, thas it has lost focus. This method schold be overrided bei derived class to react losing focus, for examlple to repaint widget losing focus.

Overrides:
unfocus in class Widget

addListener

public void addListener(jcurses.event.ActionListener listener)
Adds a listener to the button.


removeListener

public void removeListener(jcurses.event.ActionListener listener)
Removes a listener from the button.


doAction

private void doAction()

setShortCut

public void setShortCut(char c)
Set's button's shortcut char. If this shortcut is typed, than the button will handle the char, as described by Widget, and generate an Event as whether the button would be 'clicked'.


getShortCut

private jcurses.system.InputChar getShortCut()