Академический Документы
Профессиональный Документы
Культура Документы
Event Sources
A source is an object that generates an event
A source may generate more than one type event
Source must register listeners in order for listener to receive notification
about the event
General Form:
public void addTypeListener(TypeListener obj)
Listener can remove from source
Eg: button1.removeMouseListener(this)
All events has its own registration
Event Listeners
EventObject
Root class in the Java event hierarchy
Found in java.util package
Two methods: getSource(), toString()
Layout
FlowLayout
Using Insets
Insets: Space between the container that holds component and the window
that contains it
Override the getInsets() method to specify new dimension
Insets(int top, int left, int bottom, int right)
Eg:
public Insets getInsets()
{
return new Insets(10,10,10,10);
}
GridLayout
Divides the container into two dimensional grid
Class: GridLayout
GridLayout() – Single column
GridLayout(rows, cols)
GridLayout(rows, cols,hSpz,vSpz)
rows, cols can be zero, means it can have unlimited length
CardLayout