waba.ui
Class TabPanel
java.lang.Object
|
+--waba.ui.Control
|
+--waba.ui.Container
|
+--waba.ui.TabPanel
- public class TabPanel
- extends Container
TabPanel is a bar of tabs. (Very) Modified by Guich.
The panels are created automaticaly and switched when the user press the corresponding tab.
Makes an sound when the tab is pressed.
Here is an example showing a tab bar being used:
public class MyProgram extends MainWindow
{
TabPanel tp;
public void onStart()
{
String tabs[] = new String[]{"One","Two"};
tp = new TabPanel(tabs);
tp.setRect(10, 10, 80, 120);
tp.setGaps(2,2,2,2);
tp.getPanel(0).add(0,new Edit(),0,0);
tp.getPanel(1).add(0,new Label("Hi!"),0,0);
add(tabBar);
}
public void onEvent(Event event)
{
if (event.type == ControlEvent.PRESSED && event.target == tp)
{
int activeIndex = tp.getActiveTab();
... handle tab being pressed
}
}
}
Fields inherited from class waba.ui.Control |
BOTTOM,
CENTER,
controlCount,
enabled,
FILL,
fm,
font,
height,
LEFT,
name,
next,
parent,
PREFERRED,
prev,
RIGHT,
TOP,
width,
x,
y |
Constructor Summary |
TabPanel(java.lang.String[] tabCaptions)
Constructs a tab bar control. |
Method Summary |
int |
getActiveTab()
|
JustifiedContainer |
getPanel(int i)
returns the JustifiedContainer for tab |
protected void |
onBoundsChanged()
used internally. resizes all the containers. |
void |
onEvent(Event event)
Called by the system to pass events to the tab bar control. |
void |
onPaint(Graphics g)
Called by the system to draw the tab bar. |
void |
setActiveTab(int tab)
Sets the currently active tab. |
void |
setGaps(int gapL,
int gapR,
int gapT,
int gapB)
sets gaps between the containers and the TabPanel. |
Methods inherited from class waba.ui.Control |
addTimer,
contains,
createGraphics,
getAbsoluteRect,
getFontMetrics,
getNext,
getParent,
getPreferredHeight,
getPreferredWidth,
getRect,
isEnabled,
isVisible,
onWindowPaintFinished,
postEvent,
removeTimer,
repaint,
repaintNow,
setEnabled,
setFont,
setRect,
setRect,
setVisible |
Methods inherited from class java.lang.Object |
hashCode,
toString |
panels
public JustifiedContainer[] panels
TabPanel
public TabPanel(java.lang.String[] tabCaptions)
- Constructs a tab bar control.
getPanel
public JustifiedContainer getPanel(int i)
- returns the JustifiedContainer for tab
onBoundsChanged
protected void onBoundsChanged()
- used internally. resizes all the containers.
- Overrides:
- onBoundsChanged in class Control
setGaps
public void setGaps(int gapL,
int gapR,
int gapT,
int gapB)
- sets gaps between the containers and the TabPanel.
setActiveTab
public void setActiveTab(int tab)
- Sets the currently active tab. A PRESSED event will be posted to
the given tab if it is not the currently active tab. the panels will be switched.
getActiveTab
public int getActiveTab()
onEvent
public void onEvent(Event event)
- Called by the system to pass events to the tab bar control.
- Overrides:
- onEvent in class Control
- Tags copied from class: Control
- Parameters:
event
- the event to process- See Also:
Event
,
KeyEvent
,
PenEvent
onPaint
public void onPaint(Graphics g)
- Called by the system to draw the tab bar.
- Overrides:
- onPaint in class Control
- Tags copied from class: Control
- Parameters:
g
- the graphics object for drawing- See Also:
Graphics