org.zaval.lw
Class LwNotebook

java.lang.Object
  |
  +--org.zaval.util.ValidationObject
        |
        +--org.zaval.lw.LwCanvas
              |
              +--org.zaval.lw.LwPanel
                    |
                    +--org.zaval.lw.LwNotebook
All Implemented Interfaces:
Drawable, java.util.EventListener, Layoutable, LayoutContainer, LwComponent, LwContainer, LwFocusListener, LwKeyListener, LwLayout, LwMouseListener, LwTitleInfo, Validationable

public class LwNotebook
extends LwPanel
implements LwMouseListener, LwKeyListener, LwLayout, LwTitleInfo, LwFocusListener

This is notebook container. The main features of the container are shown in the list below:

The sample below illustrates the notebook container usage:

    ...
    LwNotebook n = new LwNotebook();
    n.addPage("Tab 1", new LwPanel());
    n.addPage("Tab 2", new LwPanel());
    n.addPage("Tab 3", new LwPanel());
    ...
 


Fields inherited from class org.zaval.lw.LwPanel
children
 
Fields inherited from class org.zaval.lw.LwCanvas
bits, height, insets, parent, psHeight, psWidth, skins, width, x, y
 
Fields inherited from class org.zaval.util.ValidationObject
isValidFlag
 
Constructor Summary
LwNotebook()
          Constructs a notebook container using default (Alignment.TOP) tabs alignment.
LwNotebook(int orient)
          Constructs a notebook container using the specified tabs alignment.
 
Method Summary
 void addPage(LwView v, LwComponent c)
          Adds the specified component as the notebook page and sets the specified view as.
 void addPage(java.lang.String title, LwComponent c)
          Adds the page with the specified title.
 void addSelectionListener(LwActionListener l)
          Adds the specified selection listener to receive selection events from this notebook container.
 java.awt.Dimension calcPreferredSize(LayoutContainer target)
          Calculates the preferred size dimension for the layout container.
 boolean canHaveFocus()
          Specifies if the component can have focus.
 void componentAdded(java.lang.Object id, Layoutable lw, int index)
          Invoked when the specified layoutable component is added to the layout container (that uses the layout manager).
 void componentRemoved(Layoutable lw, int index)
          Invoked when the specified layoutable component is removed from the layout container, that uses the layout manager.
 void enablePage(int index, boolean b)
          Sets the given enabled state for the specified page.
 void focusGained(LwFocusEvent e)
          Invoked when the light weight component gained focus.
 void focusLost(LwFocusEvent e)
          Invoked when the light weight component lost focus.
protected  LwLayout getDefaultLayout()
          Gets the default layout manager that is set with the container during initialization.
 LwView getPageView(int i)
          Returns the tab view for the specified page.
 int getSelectedIndex()
          Gets the tab index for the tab that is selected at the moment.
 int getTitleAlignment()
          Gets the tabs alignment.
 java.awt.Rectangle getTitleBounds()
          Gets the title size and location.
 boolean isPageEnabled(int index)
          Tests if the specified page is enabled or not.
 boolean isSelected(int i)
          Tests if the tab with the specified index is selected or not.
 void keyPressed(LwKeyEvent e)
          Invoked when a key has been pressed.
 void keyReleased(LwKeyEvent e)
          Invoked when a key has been released.
 void keyTyped(LwKeyEvent e)
          Invoked when a key has been typed.
 void layout(LayoutContainer target)
          Lays out the child layoutable components inside the layout container.
 void mouseClicked(LwMouseEvent e)
          Invoked when the mouse button has been clicked on a light weight component.
 void mouseEntered(LwMouseEvent e)
          Invoked when the mouse enters a light weight component.
 void mouseExited(LwMouseEvent e)
          Invoked when the mouse exits a light weight component.
 void mousePressed(LwMouseEvent e)
          Invoked when the mouse button has been pressed on a light weight component.
 void mouseReleased(LwMouseEvent e)
          Invoked when the mouse button has been released on a light weight component.
 void paint(java.awt.Graphics g)
          Paints this component.
protected  void perform(int index)
          Fires appropriate selection event for list of selection listeners.
protected  void recalc()
          The method is overrided by the component for internal usage.
 void remove(int i)
          Removes the component at the specified index from this container.
 void removeAll()
          Removes all child components from this container.
 void removeSelectionListener(LwActionListener l)
          Removes the specified selection listener so it no longer receives selection events from this notebook conatiner.
 void select(int index)
          Selects the tab by the specified index.
 void setTitleAlignment(int o)
          Sets the specified tabs alignment.
 
Methods inherited from class org.zaval.lw.LwPanel
add, add, calcPreferredSize, count, get, getLayoutOffset, getLwComponentAt, getLwLayout, indexOf, insert, insert, invalidate, paintOnTop, remove, setBackground, setLwLayout, setOpaque, toFront, updateCashedPs
 
Methods inherited from class org.zaval.lw.LwCanvas
getBackground, getBounds, getHeight, getInsets, getLocation, getLwParent, getOrigin, getPreferredSize, getSize, getViewMan, getVisiblePart, getWidth, getX, getY, hasFocus, isEnabled, isOpaque, isVisible, repaint, repaint, requestFocus, setEnabled, setInsets, setLocation, setLwParent, setPSSize, setSize, setViewMan, setVisible, toString, update, validate, viewManChanged, vrp
 
Methods inherited from class org.zaval.util.ValidationObject
isValid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.zaval.lw.LwComponent
getLwParent, getViewMan, getVisiblePart, setEnabled, setLwParent, setViewMan, setVisible
 
Methods inherited from interface org.zaval.lw.Drawable
getBackground, getOrigin, isEnabled, isOpaque, repaint, repaint, update
 
Methods inherited from interface org.zaval.util.Validationable
isValid, validate
 
Methods inherited from interface org.zaval.lw.Layoutable
getBounds, getHeight, getInsets, getLocation, getPreferredSize, getSize, getWidth, getX, getY, isVisible, setLocation, setSize
 

Constructor Detail

LwNotebook

public LwNotebook()
Constructs a notebook container using default (Alignment.TOP) tabs alignment.

LwNotebook

public LwNotebook(int orient)
Constructs a notebook container using the specified tabs alignment.
Parameters:
orient - the specified tabs alignement.
Method Detail

canHaveFocus

public boolean canHaveFocus()
Description copied from interface: LwComponent
Specifies if the component can have focus.
Overrides:
canHaveFocus in class LwCanvas
Following copied from interface: org.zaval.lw.LwComponent
Returns:
true if the component can have the focus.

getTitleAlignment

public int getTitleAlignment()
Gets the tabs alignment.
Specified by:
getTitleAlignment in interface LwTitleInfo
Returns:
a tabs alignment.

setTitleAlignment

public void setTitleAlignment(int o)
Sets the specified tabs alignment. The alignment can have one of following values: Alignment.TOP Alignment.BOTTOM Alignment.LEFT Alignment.RIGHT, otherwise the IllegalArgumentException will be thrown.
Parameters:
o - the specified tabs alignement.

isPageEnabled

public boolean isPageEnabled(int index)
Tests if the specified page is enabled or not.
Parameters:
index - the specified page index.
Returns:
true if the page is enaled;otherwise false.

enablePage

public void enablePage(int index,
                       boolean b)
Sets the given enabled state for the specified page.
Parameters:
index - the specified page index.
b - the given enabled state.

addPage

public void addPage(java.lang.String title,
                    LwComponent c)
Adds the page with the specified title. The method uses default tab view to render the page tab.
Parameters:
title - the specified tab title.
c - the specified page component.

addPage

public void addPage(LwView v,
                    LwComponent c)
Adds the specified component as the notebook page and sets the specified view as. the tab view.
Parameters:
v - the specified tab view.
c - the specified page component.

getPageView

public LwView getPageView(int i)
Returns the tab view for the specified page.
Parameters:
i - the specified page number.
Returns:
a tab view.

remove

public void remove(int i)
Description copied from class: LwPanel
Removes the component at the specified index from this container. The layout manager of this container is informed by calling componentRemoved method of the manager.
Overrides:
remove in class LwPanel
Following copied from class: org.zaval.lw.LwPanel
Parameters:
i - the index of the component to be removed.

removeAll

public void removeAll()
Description copied from class: LwPanel
Removes all child components from this container. The layout manager of this container is informed by calling componentRemoved method of the manager for every child that has been removed.
Overrides:
removeAll in class LwPanel

recalc

protected void recalc()
The method is overrided by the component for internal usage. Don't tuch the method.
Overrides:
recalc in class LwPanel

getSelectedIndex

public int getSelectedIndex()
Gets the tab index for the tab that is selected at the moment.
Returns:
a tab index.

paint

public void paint(java.awt.Graphics g)
Paints this component.
Overrides:
paint in class LwCanvas
Parameters:
g - the graphics context to be used for painting.

keyPressed

public void keyPressed(LwKeyEvent e)
Description copied from interface: LwKeyListener
Invoked when a key has been pressed.
Specified by:
keyPressed in interface LwKeyListener
Following copied from interface: org.zaval.lw.event.LwKeyListener
Parameters:
e - the specified key event.

mousePressed

public void mousePressed(LwMouseEvent e)
Description copied from interface: LwMouseListener
Invoked when the mouse button has been pressed on a light weight component.
Specified by:
mousePressed in interface LwMouseListener
Following copied from interface: org.zaval.lw.event.LwMouseListener
Parameters:
e - the specified mouse event.

keyReleased

public void keyReleased(LwKeyEvent e)
Description copied from interface: LwKeyListener
Invoked when a key has been released.
Specified by:
keyReleased in interface LwKeyListener
Following copied from interface: org.zaval.lw.event.LwKeyListener
Parameters:
e - the specified key event.

keyTyped

public void keyTyped(LwKeyEvent e)
Description copied from interface: LwKeyListener
Invoked when a key has been typed.
Specified by:
keyTyped in interface LwKeyListener
Following copied from interface: org.zaval.lw.event.LwKeyListener
Parameters:
e - the specified key event.

mouseEntered

public void mouseEntered(LwMouseEvent e)
Description copied from interface: LwMouseListener
Invoked when the mouse enters a light weight component.
Specified by:
mouseEntered in interface LwMouseListener
Following copied from interface: org.zaval.lw.event.LwMouseListener
Parameters:
e - the specified mouse event.

mouseExited

public void mouseExited(LwMouseEvent e)
Description copied from interface: LwMouseListener
Invoked when the mouse exits a light weight component.
Specified by:
mouseExited in interface LwMouseListener
Following copied from interface: org.zaval.lw.event.LwMouseListener
Parameters:
e - the specified mouse event.

mouseClicked

public void mouseClicked(LwMouseEvent e)
Description copied from interface: LwMouseListener
Invoked when the mouse button has been clicked on a light weight component.
Specified by:
mouseClicked in interface LwMouseListener
Following copied from interface: org.zaval.lw.event.LwMouseListener
Parameters:
e - the specified mouse event.

mouseReleased

public void mouseReleased(LwMouseEvent e)
Description copied from interface: LwMouseListener
Invoked when the mouse button has been released on a light weight component.
Specified by:
mouseReleased in interface LwMouseListener
Following copied from interface: org.zaval.lw.event.LwMouseListener
Parameters:
e - the specified mouse event.

componentAdded

public void componentAdded(java.lang.Object id,
                           Layoutable lw,
                           int index)
Description copied from interface: LwLayout
Invoked when the specified layoutable component is added to the layout container (that uses the layout manager). The specified constraints, layoutable component and child index are passed as arguments into the method.
Specified by:
componentAdded in interface LwLayout
Following copied from interface: org.zaval.lw.LwLayout
Parameters:
id - the layoutable component constraints.
lw - the layoutable component that has been added.
index - the child index.

componentRemoved

public void componentRemoved(Layoutable lw,
                             int index)
Description copied from interface: LwLayout
Invoked when the specified layoutable component is removed from the layout container, that uses the layout manager.
Specified by:
componentRemoved in interface LwLayout
Following copied from interface: org.zaval.lw.LwLayout
Parameters:
lw - the layoutable component that has been removed.
index - the child component index.

calcPreferredSize

public java.awt.Dimension calcPreferredSize(LayoutContainer target)
Description copied from interface: LwLayout
Calculates the preferred size dimension for the layout container. The method has to calculate "pure" preferred size, it means that an insets of the container should not be considered.
Specified by:
calcPreferredSize in interface LwLayout
Following copied from interface: org.zaval.lw.LwLayout
Parameters:
target - the layout container.
Returns:
a "pure" preferred size.

layout

public void layout(LayoutContainer target)
Description copied from interface: LwLayout
Lays out the child layoutable components inside the layout container.
Specified by:
layout in interface LwLayout
Following copied from interface: org.zaval.lw.LwLayout
Parameters:
target - the layout container that needs to be laid out.

select

public void select(int index)
Selects the tab by the specified index. Use -1 index value to de-select current selected tab, in this case no one tab will be selected.
Parameters:
index - the specified item index.

isSelected

public boolean isSelected(int i)
Tests if the tab with the specified index is selected or not.
Returns:
true if the tab with the specified index is selected; otherwise false.

addSelectionListener

public void addSelectionListener(LwActionListener l)
Adds the specified selection listener to receive selection events from this notebook container.
Parameters:
l - the specified listener.

removeSelectionListener

public void removeSelectionListener(LwActionListener l)
Removes the specified selection listener so it no longer receives selection events from this notebook conatiner.
Parameters:
l - the specified listener.

getTitleBounds

public java.awt.Rectangle getTitleBounds()
Description copied from interface: LwTitleInfo
Gets the title size and location. The bounds usage depends on the title alignment:
Specified by:
getTitleBounds in interface LwTitleInfo
Following copied from interface: org.zaval.lw.LwTitleInfo
Returns:
a title size and location.

focusGained

public void focusGained(LwFocusEvent e)
Description copied from interface: LwFocusListener
Invoked when the light weight component gained focus.
Specified by:
focusGained in interface LwFocusListener
Following copied from interface: org.zaval.lw.event.LwFocusListener
Parameters:
e - the specified focus event.

focusLost

public void focusLost(LwFocusEvent e)
Description copied from interface: LwFocusListener
Invoked when the light weight component lost focus.
Specified by:
focusLost in interface LwFocusListener
Following copied from interface: org.zaval.lw.event.LwFocusListener
Parameters:
e - the specified focus event.

perform

protected void perform(int index)
Fires appropriate selection event for list of selection listeners. The method performs LwActionEvent as the selection event where the getData method returns the tab index that has been selected
Parameters:
index - the tab index that has been selected.

getDefaultLayout

protected LwLayout getDefaultLayout()
Gets the default layout manager that is set with the container during initialization. The component defines itself as the default layout. Don't use any other layout for the component, in this case the working of the component can be wrong.
Overrides:
getDefaultLayout in class LwPanel
Returns:
a layout manager.


Copyright © Zaval Creative Engineering Group, 2000-2005.
http://www.zaval.org