ClassX is a Lightweight Java GUI alternative to Swing.
| JAVA ClassX GUI Framework | |||
![]() |
Overview An overview of the ClassX Implementation. Includes an explanation of Main.java and the Menu classes. |
||
![]() |
Menu.java An outline of how to use each of the menu java files, defining the makeup of each display page on the applet. |
||
![]() |
Main.java An outline of how to use the main commanding class file that controls the whole GUI. |
||
![]() |
ClassX.java An outline of how to use any of the ClassX class files that control the GUI. |
||
| JAVA ClassX Components | |||
![]() |
ScrollTree The ScrollTree Component. |
||
![]() |
ScrollList The ScrollList Component. |
||
![]() |
TextArea A full set of components that can be used as an alternative to Swing. |
||
![]() |
PieChart A full set of components that can be used as an alternative to Swing. |
||
![]() |
BarChart A full set of components that can be used as an alternative to Swing. |
||
![]() |
Button A full set of components that can be used as an alternative to Swing. |
||
![]() |
CheckBox A full set of components that can be used as an alternative to Swing. |
||
![]() |
ImageLabel A full set of components that can be used as an alternative to Swing. |
||
|
|||
Overview
ClassX is a Lightweight Java GUI alternative to Swing.
The code is free to download, if anyone wants to adapt/improve/change it please
go ahead, all I ask is if you could let me know if you do anything quite interesting
with it.
Menu.java
The class that defines a page of the GUI.
Each display page of the final GUI is defined in a single java Menu file. I
have used the convention that each display page is of the form _____Menu.java
so I instantly know which pages are display pages, you can use any convention
you want. In a java Menu page the display page is defined in terms of it's components
and is functionality is programmed, below is an example (the TextArea display
page from the demonstration).
public class DemoTextMenu extends
ClassX {
|
As with all files except Main.java all files extend ClassX.java.
First(in blue)
the name of this display page is defined, how it will appear on the screen ("TextArea")
and how it will be defined within the program ("text"). Then components
to be used are defined (in red), and added to the screen (light green). A number
of functions are carried out in the setup method (in orange). And finally in
dark Green there is the fire method, which catches interaction from the user
for all three components, a case statement for each component (if a button is
pressed or a list item chosen it triggers the fire method).
In this example the fire method prints out a line of text, but of course this
would be different for each page.
Main.java
The controlling class file that runs the GUI.
On the whole, an applet can be written without the need for really any changes
to the Main.java source. There are however some changes that must be made. Each
page of the tabbed display is created in a java file usually with the Menu.java
extension, each one of these display pages to be used must be included in the
setup and setMenu methods of Main.java.
|
Here is a
excerpt of a listing of Main.java taken from the demonstration applet, each
of the display pages to be used are intialised in blue, their order being the
order they will appear on the tabs. In red then next a menu is defined, all
display pages to be used being set visible, and the one showing to be selected.
This can be done for any number of menus, of arrangements of display pages,
from within a menu page you then simply call parent.setMenu("1");
say for menu "1" definition. Likewise if you want to access the components/methods
of another display page say the display page DemoTextMenu.java (from within
another display page), defined within the code as "text" and you want
to run a method called setup() you can call ((DemoTextMenu)parent.get("text")).setup();
ClassX.java
The class that defines each component of a page.
Each display page and component extends the class ClassX, and as such has various
methods associated with it.
For example a ScrollList called S1 can be enabled or disabled using :-
S1.enable();
S1.disable();
Similarly
a display page has the method onLeave for when a user leaves the page, by putting
this method in a ____Menu.java file it will be called when the page is left.
Main.java
The controlling class file that runs the GUI.
On the whole, an applet can be written without the need for really any changes
to the Main.java source. There are however some changes that must be made. Each
page of the tabbed display is created in a java file usually with the Menu.java
extension, each one of these display pages to be used must be included in the
setup and setMenu methods of Main.java.
|
Here is a
excerpt of a listing of Main.java taken from the demonstration applet, each
of the display pages to be used are intialised in blue, their order being the
order they will appear on the tabs. In red then next a menu is defined, all
display pages to be used being set visible, and the one showing to be selected.
This can be done for any number of menus, of arrangements of display pages,
from within a menu page you then simply call parent.setMenu("1");
say for menu "1" definition. Likewise if you want to access the components/methods
of another display page say the display page DemoTextMenu.java (from within
another display page), defined within the code as "text" and you want
to run a method called setup() you can call ((DemoTextMenu)parent.get("text")).setup();
ScrollTree
The controlling class file that runs the GUI.
|
Its selection
is then captured in the fire method.
ScrollList
The ScrollList
component.
|
The lists type is then set as -
S2.unSelect(true);
can unselect a list item when it is clicked when already selected.
S2.Pics(true);
Pictures are associated wih each item
S2.setMultiple(true);
It is to have multiple selection properties
S2.DblClick(false);
It can be selected with a single (not double) click
Default is single click, single selection without pictures.
For a single selection list in the fire method the selected item can be refered
to as :-
(item)S2.names.elementAt(S2.selected)
For a multiple selection list in the fire method it's selection is a vector
and has to be obtained using:-
Vector selectionlist=S2.catchMultiple();
TextArea
The TextArea Component.
Pie
Chart
The PieChart Component.
Bar
Chart
The BarChart Component.
This component
can be created using
C1=new CheckBox(parent,parent.oG,100,250,false);
Arguments :-
parent (always present)
parent.oG (always present)
100,250 (The x and y position on the page)
false (Its initial state, checked or unchecked, in this case unchecked)
The methods
C1.set(true) or C1.set(false) can also be used on this component.
If pressed the method fire is called. Its value is determined by C1.get() which
returns true or false.
ImageLabel
The ImageLabel
Component.