: Download: FAQ: Licensing: Support: Contact ME
LwVCL Home
Introduction
Overview
Screen Shots
On-line Demos
Requirements
Further Plans
Docs
Tutorial
How-to (PDF)
API
FAQ
Download
Latest version

Home > J2SE > API

Overview  Package   Class  Tree  Deprecated  Index  Help 

org.zaval.lw
Class LwNotebook

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

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

This is notebook container. The main features of the container are listed below:

  • The page tabs can be laid out using "right", "left", "top" or "bottom" alignments. The default tabs alignment is "top".
  • It is possible to use any views or string title as tabs views. The appropriate tab view can be passed as an argument of the addPage method.
  • The add, insert, remove methods can be used to change the notebook pages content.
  • The enablePage, isPageEnabled methods can be used to change enabled state of the specified page.
  • The container implements and uses own layout manager, so it is undesirable to use any other layout manager for the notebook container.
  • To listen when a page of the container has been selected use addSelectionListener and removeSelectionListener methods. The passed data argument is selected tab index.
  • It is possible to customize the tabs borders views for the selected and unselected tab states. Use the setView method for this purpose.
  • It is possible to customize the tabs borders marker view. Use the setView method for this purpose.

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());

    // Add the image as the tab view
    n.addPage(new LwImgRender("/imgs/tab.gif", LwView.ORIGINAL), new LwPanel());

    ...
 


Field Summary
static int MARKER_VIEW
          The selection marker view id.
static int STABBR_VIEW
          The selected tab border view id.
static int TABBR_VIEW
          The tab border view id.
 
Fields inherited from class org.zaval.lw.LwPanel
children
 
Fields inherited from class org.zaval.lw.LwCanvas
bits, bottom, height, isValidValue, left, parent, psHeight, psWidth, right, skins, temporary, top, width, x, y
 
Constructor Summary
LwNotebook()
          Constructs a notebook container using default (LwToolkit.TOP) tabs alignment.
LwNotebook(int o)
          Constructs a notebook container using the specified tabs alignment.
 
Method Summary
 void addPage(java.lang.Object 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.
protected  int calcInsets(int type, int ci, int bi)
          Calculates and returns the given inset.
 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 was added to the layout container (that uses the layout manager).
 void componentRemoved(Layoutable lw, int index)
          Invoked when the specified layoutable component was removed from the layout container, that uses the layout manager.
protected  void drawMarker(java.awt.Graphics g, java.awt.Rectangle r)
          Renders the marker for the specified tab bounds using the given graphical context.
 void enablePage(int index, boolean b)
          Sets the given enabled state for the specified page.
 void focusGained(LwVCLEvent e)
          Invoked when the light weight component gained focus.
 void focusLost(LwVCLEvent 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.
 int getSelectedIndex()
          Gets the tab index of the selected tab.
 int[] getSpaces()
          Returns extra indents for the selected tab.
 int getTabAt(int x, int y)
          Gets the tab index that is located at the given location.
protected  java.awt.Rectangle getTabBounds(int index)
          Gets the tab bounds.
 int getTabHGap()
          Returns the tab horizontal gap.
 int getTabVGap()
          Returns the tab vertical gap.
protected  LwView getTabView(int index)
          Gets the view for the specified tab.
 int getTitleAlignment()
          Gets the tabs alignment.
 java.awt.Rectangle getTitleBounds()
          Gets the title size and location.
 LwView getView(int type)
          Returns the view of the given element type.
 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 paintTab(java.awt.Graphics g, int pageIndex)
          Renders the given tab using the given graphical context.
protected  void perform(int index)
          Fires appropriate selection event for list of selection listeners.
protected  void recalc()
          The method is overridden 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 repaint(boolean b)
          Invoked whenever the component got or lost the focus.
 void select(int index)
          Selects the tab by the specified index.
 void setGaps(int vg, int hg)
          Sets the notebook layout gaps.
 void setSize(int w, int h)
          Sets the specified size for this component.
 void setTabSpaces(int vg, int hg, int sideSpace, int upperSpace, int brSpace)
          Sets the tab metrics.
 void setTitle(int pageIndex, java.lang.Object data)
          Sets the specified page title.
 void setView(int type, LwView t)
          Sets the specified view for the given element type.
 
Methods inherited from class org.zaval.lw.LwPanel
add, add, calcPreferredSize, count, get, getLayoutOffset, getLwComponentAt, getLwLayout, getPreferredSize, indexOf, insert, insert, invalidate, isInvalidatedByChild, laidout, paintOnTop, remove, setBackground, setLwLayout, setOpaque, toFront, updateCashedPs, validate
 
Methods inherited from class org.zaval.lw.LwCanvas
customize, cvp, getBackground, getBottom, getBounds, getHeight, getInsets, getLeft, getLocation, getLwParent, getOrigin, getPSImpl, getRight, getSize, getTop, getViewMan, getVisiblePart, getWidth, getX, getY, hasFocus, isEnabled, isOpaque, isValid, isVisible, repaint, repaint, requestFocus, setEnabled, setInsets, setLocation, setLwParent, setPSSize, setViewMan, setVisible, update, viewManChanged, vrp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.zaval.lw.LwComponent
getBackground, getLwParent, getOrigin, getViewMan, getVisiblePart, isEnabled, isOpaque, repaint, repaint, setEnabled, setInsets, setLwParent, setViewMan, setVisible, update
 
Methods inherited from interface org.zaval.lw.Layoutable
getBounds, getHeight, getInsets, getLocation, getSize, getWidth, getX, getY, isVisible, setLocation
 
Methods inherited from interface org.zaval.util.Validationable
isValid
 

Field Detail

TABBR_VIEW

public static final int TABBR_VIEW
The tab border view id.

STABBR_VIEW

public static final int STABBR_VIEW
The selected tab border view id.

MARKER_VIEW

public static final int MARKER_VIEW
The selection marker view id.
Constructor Detail

LwNotebook

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

LwNotebook

public LwNotebook(int o)
Constructs a notebook container using the specified tabs alignment.
Parameters:
o - the specified tabs alignement. Use one of the following constants as the argument value:
  • LwToolkit.LEFT - to have tabs placed to the left of the component.
  • LwToolkit.RIGHT - to have tabs placed to the right of the component.
  • LwToolkit.TOP - to have tabs placed from the top of the component.
  • LwToolkit.BOTTOM - to have tabs placed from the bottom of the component.
Method Detail

setView

public void setView(int type,
                    LwView t)
Sets the specified view for the given element type.
Parameters:
type - the given element type. Use the TABBR_VIEW (tab border view), STABBR_VIEW (selected tab border) or MARKER_VIEW (marker) constants as the argument value.
t - the specified view.

repaint

public void repaint(boolean b)
Description copied from interface: LwComponent
Invoked whenever the component got or lost the focus. The method is supposed to optimize the performance of the focus marker, since in most cases it is not necessary to repaint all component area. By default the method repaint all component area.
Overrides:
repaint in class LwCanvas
Following copied from interface: org.zaval.lw.LwComponent
Parameters:
b - true if the component has got the focus, and false if the component lost the focus.

getView

public LwView getView(int type)
Returns the view of the given element type.
Parameters:
type - the given element type. Use the TABBR_VIEW (tab border view), STABBR_VIEW (selected tab border) or MARKER_VIEW (marker) constants as the argument value.
Returns:
an element view.

setTabSpaces

public void setTabSpaces(int vg,
                         int hg,
                         int sideSpace,
                         int upperSpace,
                         int brSpace)
Sets the tab metrics.
Parameters:
vg - the vertical gap between the tab border and the tab view.
hg - the horizontal gap between the tab border and the tab view.
sideSpace - the selected tab extra indent. The indent is used to extend selected tab size.
brSpace - the border indent.

getSpaces

public int[] getSpaces()
Returns extra indents for the selected tab.
Returns:
extra indents.

getTabVGap

public int getTabVGap()
Returns the tab vertical gap.
Returns:
a vertical gap.

getTabHGap

public int getTabHGap()
Returns the tab horizontal gap.
Returns:
a horizontal gap.

setGaps

public void setGaps(int vg,
                    int hg)
Sets the notebook layout gaps. The gaps are used as the vertical and horizontal indents to place content components.
Parameters:
vg - the vertical layout gap.
hg - the horizontal layout gap.

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 TitleInfo
Returns:
a tabs alignment.

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.Object title,
                    LwComponent c)
Adds the page with the specified title.
Parameters:
title - the specified tab title. It is possible to use a string or a view as the title value.
c - the specified page component.

setTitle

public void setTitle(int pageIndex,
                     java.lang.Object data)
Sets the specified page title.
Parameters:
pageIndex - the specified page index.
data - the specified tab title. It is possible to use a string or a view as the title value.

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 overridden by the component for internal usage. Don't tuch the method.
Overrides:
recalc in class LwCanvas

getSelectedIndex

public int getSelectedIndex()
Gets the tab index of the selected tab.
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 was 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 was 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 container insets should not be taken into account.
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.

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. The listener gets the selected index value as the data argument of the action listener.
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: TitleInfo
Gets the title size and location. The bounds usage depends on the title alignment:
  • If the alignment is LwToolkit.BOTTOM or LwToolkit.TOP than the appropriate title border view will use y coordinate to locate the border and x coordinate is calculated depending on the title border alignment.
  • If the alignment is LwToolkit.LEFT or LwToolkit.RIGHT than the appropriate title border view will use x coordinate to locate the border and y coordinate is calculated depending on the title border alignment.
Specified by:
getTitleBounds in interface TitleInfo
Following copied from interface: org.zaval.lw.TitleInfo
Returns:
a title size and location.

focusGained

public void focusGained(LwVCLEvent 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(LwVCLEvent 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.

getTabAt

public int getTabAt(int x,
                    int y)
Gets the tab index that is located at the given location.
Parameters:
x - the specified x coordinate.
y - the specified y coordinate.
Returns:
a tab index. The method returns -1 if no one tabs can be found at the specified location.

setSize

public void setSize(int w,
                    int h)
Description copied from interface: Layoutable
Sets the specified size for this component.
Overrides:
setSize in class LwPanel
Following copied from interface: org.zaval.lw.Layoutable
Parameters:
w - the width of this component.
h - the height of this component.

perform

protected void perform(int index)
Fires appropriate selection event for list of selection listeners. The method performs selection events. The passed data argument identifies a selected tab index. The argument is represeted as java.lang.Integer object.
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.

getTabView

protected LwView getTabView(int index)
Gets the view for the specified tab.
Parameters:
index - the specified tab index.
Returns:
a tab view.

drawMarker

protected void drawMarker(java.awt.Graphics g,
                          java.awt.Rectangle r)
Renders the marker for the specified tab bounds using the given graphical context.
Parameters:
g - the specified context to be used for painting.
r - the specified tab bounds.

calcInsets

protected int calcInsets(int type,
                         int ci,
                         int bi)
Description copied from class: LwCanvas
Calculates and returns the given inset.
Overrides:
calcInsets in class LwCanvas
Following copied from class: org.zaval.lw.LwCanvas
Parameters:
type - the inset type. Use LwToolkit.TOP, LwToolkit.LEFT, LwToolkit.RIGHT, LwToolkit.BOTTOM as the argument value.
ci - the component inset.
bi - the border inset.
Returns:
an inset.

paintTab

protected void paintTab(java.awt.Graphics g,
                        int pageIndex)
Renders the given tab using the given graphical context.
Parameters:
g - the specified context to be used for painting.
pageIndex - the specified tab index.

getTabBounds

protected java.awt.Rectangle getTabBounds(int index)
Gets the tab bounds. The returned bounds is not a copy, it means you should not change its fields since it can bring to fault.
Parameters:
index - the specified tab index.
Returns:
a tab bounds.


: up