-
Notifications
You must be signed in to change notification settings - Fork 9
Tab Groups
As well as the large side-bar type Tabs
element, JISA
allows you to create a more traditional tab-pane type Container
element called a TabGroup
.
To create a TabGroup
, just like any other Element
, you need only instantiate a TabGroup
object and provide it with a title:
TabGroup tabGroup = new TabGroup("My Tab Group");
You can then add elements to it using the add(...)
or addAll(...)
methods as you would any other container. The title of each element is used as the title for the tab itself.
Java
TabGroup tabGroup = new TabGroup("Results");
Plot plot = new Plot("Plot", "X", "Y");
Table table = new Table("Table");
tabGroup.addAll(plot, table);
Kotlin
val tabGroup = TabGroup("Results")
val plot = Plot("Plot", "X", "Y")
val table = Table("Table")
tabGroup.addAll(plot, table)
Python
tabGroup = TabGroup("Results")
plot = Plot("Plot", "X", "Y")
table = Table("Table")
tabGroup.addAll([plot, table])
The result of this is the following. Clicking on each tab will change the contents underneath to be that of its respective element.
Alternatively, like with Grid
and Tabs
, you can add elements in the constructor like so:
Java
TabGroup tabGroup = new TabGroup("Results", plot, table);
Kotlin
val tabGroup = TabGroup("Results", plot, table)
Python
tabGroup = TabGroup("Results", [plot, table])
Similar to how you can specify the side the legend appears on in a Plot
, you can specify which side the tabs are shown on (ie TOP
, RIGHT
, BOTTOM
or LEFT
) using the setTabsPosition(...)
method like so:
tabGroup.setTabsPosition(Side.TOP);
tabGroup.setTabsPosition(Side.RIGHT);
tabGroup.setTabsPosition(Side.BOTTOM);
tabGroup.setTabsPosition(Side.LEFT);
You can programmatically set or check which tab is selected using the select(...)
, getSelectedIndex()
and getSelectedElement()
methods.
If you have the Element
object itself that you wish to be selected, you can simply pass it to the select(...)
method like so:
Plot plot = new Plot("Plot", "X", "Y");
Table table = new Table("Table");
TabGroup tabGroup = new TabGroup("Results", plot, table);
tabGroup.select(table);
Alternatively, you can specify its index (starting at zero). In this case, we want the Table
to be selected which is the second element, hence index 1
:
tabGroup.select(1);
To check which is selected, you can either request the Element
object that is currently selected or its index:
Element selected = tabGroup.getSelectedElement();
int index = tabGroup.getSelectedIndex();
For instance, to check if the Table
element is currently selected:
if (tabGroup.getSelectedElement() == table) {
// Table is selected
}
- Getting Started
- Object Orientation
- Choosing a Language
- Using JISA in Java
- Using JISA in Python
- Using JISA in Kotlin
- Exceptions
- Functions as Objects
- Instrument Basics
- SMUs
- Thermometers (and old TCs)
- PID and Temperature Controllers
- Lock-Ins
- Power Supplies
- Pre-Amplifiers
- Writing New Drivers