vipratech.beans.standardbeans
Class TabPanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--vipratech.awt.VPanel
                          |
                          +--vipratech.beans.standardbeans.TabPanel

public class TabPanel
extends VPanel

The TabPanel.class provides a tabbed panel for GUIs. By default 3 tabs and panels are provided.

The labels for the tabs should be set up in the various localised resource bundles (for example, LabelsBundle_en_US). The bean checks all labels for all locales and then sets the tab width to the longest string that was found. This ensures that tab label text will be visible, whatever the selected locale.

The locale can be selected at design time or by the user at run time it the button is wired to vipratech.beans.standardbeans.LanguageChoice.

Various utility methods such as tab sizing and drawing are set up in the vipratech.beans.standardbeans.TabSupport class.

Version:
1.03, January 30, 2000
Author:
Warwick Bailey   warwick-bailey@bigfoot.com
See Also:
TabSupport, Serialized Form

Fields inherited from class vipratech.awt.VPanel
fm
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
TabPanel()
          Constructor
 
Method Summary
 void drawActiveTab(java.awt.Graphics g)
          Indetifies and draws the active tab.
 void drawAllTabs(java.awt.Graphics g)
          Draws all the tabs as inactive.
 void findSelectedTab(int x)
          Tests the mouse release to find the selected tab.
 int getCurrentPanel()
          Sets the panel and tab to be displayed.
 java.util.Locale[] getDefaultLocales()
          An indexed array of locales that are supported.
 java.awt.Insets getInsets()
          Returns the insets around this component.
 java.lang.String getLanguage()
          Returns the language for this component.
 java.util.Locale getLocale()
          Returns the locale for this component.
 java.lang.String getLongestLocalisedLabel(java.lang.String key)
          Loops through all possible language labels and finds the longest string.
 java.awt.Dimension getMinimumSize()
          Returns the minumum size.
 int getNumberOfTabs()
          Returns the number of tabs displayed.
 VPanel[] getPanel()
           
 VPanel[] getPanelArray()
          Returns an array of panels.
 java.lang.String[] getTabLabel()
          Returns an array of labels according to the current locale of the TabPanel.
 java.awt.Dimension[] getTabSize()
          Sizes the tab for the longest label out of all possible localised language labels that are available from resource bundles.
 boolean[] getTabState()
          Returns an array of tab states.
 void initialise()
          Sets up array of labels, tab states and tab dimensions.
 void mouse_released_action(int x, int y)
          Processes the mouse released event.
 boolean onTabs(int y)
          Tests the mouse release.
 void paint(java.awt.Graphics g)
          Draws the 3D panel border and tabs.
 void propertyChange(java.beans.PropertyChangeEvent event)
          Allows this component to be wired up to vipratech.beans.LanguageChoice at design time.
 void setCurrentPanel(int currentPanel)
          Sets the panel and tab to be displayed.
 void setLanguage(java.lang.String language)
          Sets the language to be used for this component.
 void setLocale(java.util.Locale locale)
          Sets the locale for this component.
 void setNumberOfTabs(int numberOfTabs)
          Sets the number of tabs to be displayed.
 void setPanel(VPanel[] panel)
           
 void showPanel(int currentPanel)
          Displays the selected panel.
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, getMaximumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, disable, dispatchEvent, enable, enable, enableInputMethods, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TabPanel

public TabPanel()
Constructor
Method Detail

initialise

public void initialise()
Sets up array of labels, tab states and tab dimensions. Initliases the first tab to be show as active.

getTabLabel

public java.lang.String[] getTabLabel()
Returns an array of labels according to the current locale of the TabPanel. The collection of tab labels should be set up in the resource bundles.

getDefaultLocales

public java.util.Locale[] getDefaultLocales()
An indexed array of locales that are supported.

getTabState

public boolean[] getTabState()
Returns an array of tab states. All tabs are set to inactive, except for the first tab which is active in the initialisation() method.

getTabSize

public java.awt.Dimension[] getTabSize()
Sizes the tab for the longest label out of all possible localised language labels that are available from resource bundles.

getLongestLocalisedLabel

public java.lang.String getLongestLocalisedLabel(java.lang.String key)
Loops through all possible language labels and finds the longest string. The longest label string is the used to set the width of the tab.

getPanelArray

public VPanel[] getPanelArray()
Returns an array of panels. This method also add each panel to the parent container and then removes the panel. This initialises the display of each panel and avoids first time draw flicker.

mouse_released_action

public void mouse_released_action(int x,
                                  int y)
Processes the mouse released event. Checks the mouse release is within the tab height and then finds which tab was clicked.

onTabs

public boolean onTabs(int y)
Tests the mouse release. Returns true is the mouse release is within the tab height.

findSelectedTab

public void findSelectedTab(int x)
Tests the mouse release to find the selected tab.

showPanel

public void showPanel(int currentPanel)
Displays the selected panel. The selected tab is also set to be active.

drawAllTabs

public void drawAllTabs(java.awt.Graphics g)
Draws all the tabs as inactive.

drawActiveTab

public void drawActiveTab(java.awt.Graphics g)
Indetifies and draws the active tab. The active tab is drawn over the sequence of inactive tabs.

paint

public void paint(java.awt.Graphics g)
Draws the 3D panel border and tabs.
Overrides:
paint in class java.awt.Container

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Allows this component to be wired up to vipratech.beans.LanguageChoice at design time. The property name of "locale" is used as the property name.

getMinimumSize

public java.awt.Dimension getMinimumSize()
Returns the minumum size.
Overrides:
getMinimumSize in class java.awt.Container

getInsets

public java.awt.Insets getInsets()
Returns the insets around this component.
Overrides:
getInsets in class java.awt.Container

setLocale

public void setLocale(java.util.Locale locale)
Sets the locale for this component.
Overrides:
setLocale in class java.awt.Component

getLocale

public java.util.Locale getLocale()
Returns the locale for this component.
Overrides:
getLocale in class java.awt.Component

setLanguage

public void setLanguage(java.lang.String language)
Sets the language to be used for this component. An ISO639 language code of two lower case letters reprenting a language should be passed as the argument. Only those languages that are listed in vipratech.bui.InterfaceProperties can be set. (Examples: "de", "en" etc.).

getLanguage

public java.lang.String getLanguage()
Returns the language for this component.

setNumberOfTabs

public void setNumberOfTabs(int numberOfTabs)
Sets the number of tabs to be displayed.

getNumberOfTabs

public int getNumberOfTabs()
Returns the number of tabs displayed.

setCurrentPanel

public void setCurrentPanel(int currentPanel)
Sets the panel and tab to be displayed. The panels are numbered as for arrays, with the first panel numbered 0 (zero). This method is particularly useful at design time so that each panel can have components added to it at design time.

getCurrentPanel

public int getCurrentPanel()
Sets the panel and tab to be displayed. The panels are numbered as for arrays, with the first panel numbered 0 (zero).

setPanel

public void setPanel(VPanel[] panel)

getPanel

public VPanel[] getPanel()

dathe@chemie.uni-leipzig.de"

http://leipzig.vernetztes-studium.de