-
Notifications
You must be signed in to change notification settings - Fork 9
GUI Elements
To make cohesive user-interfaces with minimal effort, JISA
provides several graphical "blocks" that you can combine to create graphical user interfaces without having to build them from scratch yourself. These are called "elements" and include plots, tables, user-input fields, toolbars, grids and tabs. These all derive from the JFXWindow
class thus they all share some common basic functionality.
This page serves as a guide on this shared functionality including window control (opening, closing, maximising etc), creating layouts and defining what happens when the user closes a window.
- Opening and Closing Windows
- Extra Window Features
- Containers
- JFXWindow/Element Method Reference
- Container Method Reference
All GUI elements can be shown separately in their own window. After creating such an element, for example a Table
, we can make it show-up in its own window by use of show()
like so:
Table window = new Table("Title");
window.show();
This results in
You can then make it close by use of:
window.close();
or just to quickly hide it (it closes the window but keeps it in memory):
window.hide();
Sometimes, you may wish for your window to maximise, to do this you can use the setMaximised(...)
method like so:
window.setMaximised(true); // This will make the window maximised
window.setMaximised(false); // This will un-maximise the window
Aditionally, if a window is the "main" window then you might want it to terminate the program if closed. To set this use setExitOnClose(...)
like so:
window.setExitOnClose(true); // Terminates execution when window is closed
window.setExitOnClose(false); // Does not terminate when closed
Some GUI elements act as "containers". That is they exist to hold other GUI elements together in a single window. These elements implement the Container
interface as well as being subclasses of JFXWindow
, so they provide all the same common functionality as any other GUI element, but with some additions.
To look at this, let's start by creating an example:
Plot plot = new Plot("My Plot", "X", "Y");
Table table = new Table("My Table");
// Grid is a "container" that displays elements in a grid
Grid container = new Grid("My Grid");
So we now have a Plot
element and a Table
element as well as our container, which is a Grid
in this case.
We can add elements, one at a time, to a container by use of add(...)
like so:
container.add(plot);
container.add(table);
alternatively you can add multiple elements at once by use of addAll(...)
:
container.addAll(plot, table);
Either way, when we show call show()
on the container:
container.show();
we get this:
You can also remove an element from a container by specifying the element like so:
container.remove(elementToRemove);
or multiple elements like this:
container.removeAll(elementToRemove1, elementToRemove2, elementToRemove3); // etc
You can also remove all elements by use of:
container.clear();
Method | Description |
---|---|
window.show(); |
Makes the GUI element show itself in its own window. |
window.hide(); |
Make the open window close whilst remaining active in memory. |
window.close(); |
Makes the GUI element close and remove itself from memory. |
window.setMaximised(boolean max); |
Sets whether the window is maximised or not. |
window.close(); |
Makes the GUI element close and remove itself from memory. |
window.setExitOnClose(boolean exit); |
Sets whether the program should terminate when this window is closed. |
Method | Description |
---|---|
container.add(Element e); |
Adds the specified GUI element to the container. |
container.addAll(Element... e); |
Adds all the specified GUI elements to the container in order. |
container.addAll(Collection<Element> e); |
Adds all the GUI elements in the collection to the container. |
container.remove(Element e); |
Removes the specified element from the container (if it is present). |
container.removeAll(Element... e); |
Removes all the specified elements from the container (if present). |
container.removeAll(Collection<Element> e); |
Removes all the elements in the collection from the container (if present). |
container.clear(); |
Removes all elements from the container. |
List<Element> list = container.getElements(); |
Returns a list of all elements in the container. Changes to this list do not propagate back to the container. |
- 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