ch.sahits.game.graphic.layout
Class Button

java.lang.Object
  extended by ch.sahits.game.graphic.layout.AbstractSahitsComponent
      extended by ch.sahits.game.graphic.layout.Button
All Implemented Interfaces:
ISahitsComponent, IUpdatableComponent

public class Button
extends AbstractSahitsComponent
implements IUpdatableComponent


Field Summary
private  Runnable action
           
private  Font font
           
private  int H_BORDER
           
private  FontMetrics metric
           
private  String text
           
private  int V_BORDER
           
 
Fields inherited from class ch.sahits.game.graphic.layout.AbstractSahitsComponent
painter
 
Constructor Summary
Button(FontMetrics fm)
           
 
Method Summary
 void gameRender(Graphics gScr)
          Force the panel to render itself.
 void gameUpdate()
          Force the panel to update its state.
 Font getFont()
          Retrieve the font
 Dimension getPreferredSize()
          Retrieve the preferred size of the component.
 String getText()
           
 void paint(Graphics g)
          Draw the component with the appropriate graphic context.
 void setAction(Runnable run)
           
 void setFont(Font f)
          Set the font
 void setText(String text)
           
 void testClick(Point p)
          Test if there was a mouse click on the component
 void testKeyPress(KeyEvent e)
          Check the updatable components if the key press was in one of them
 
Methods inherited from class ch.sahits.game.graphic.layout.AbstractSahitsComponent
createVisualBounds, getBounds, getInsets, setBounds, setInsets
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

font

private Font font

metric

private final FontMetrics metric

text

private String text

V_BORDER

private int V_BORDER

H_BORDER

private int H_BORDER

action

private Runnable action
Constructor Detail

Button

public Button(FontMetrics fm)
Method Detail

gameRender

public void gameRender(Graphics gScr)
Description copied from interface: IUpdatableComponent
Force the panel to render itself.

Specified by:
gameRender in interface IUpdatableComponent
Parameters:
gScr - Graphics used for the rendering

gameUpdate

public void gameUpdate()
Description copied from interface: IUpdatableComponent
Force the panel to update its state.

Specified by:
gameUpdate in interface IUpdatableComponent

paint

public void paint(Graphics g)
Description copied from interface: ISahitsComponent
Draw the component with the appropriate graphic context. Before calling this method make sure it is appropriately initialized.

Specified by:
paint in interface ISahitsComponent

getPreferredSize

public Dimension getPreferredSize()
Description copied from interface: ISahitsComponent
Retrieve the preferred size of the component.

Specified by:
getPreferredSize in interface ISahitsComponent
Returns:

getFont

public Font getFont()
Description copied from interface: ISahitsComponent
Retrieve the font

Specified by:
getFont in interface ISahitsComponent
Returns:

setFont

public void setFont(Font f)
Description copied from interface: ISahitsComponent
Set the font

Specified by:
setFont in interface ISahitsComponent

testClick

public void testClick(Point p)
Description copied from interface: IUpdatableComponent
Test if there was a mouse click on the component

Specified by:
testClick in interface IUpdatableComponent

testKeyPress

public void testKeyPress(KeyEvent e)
Description copied from interface: IUpdatableComponent
Check the updatable components if the key press was in one of them

Specified by:
testKeyPress in interface IUpdatableComponent

getText

public String getText()

setText

public void setText(String text)

setAction

public void setAction(Runnable run)


Copyright © 2011 Sahits GmbH. All Rights Reserved.