Libresource
Home
Search
My Page
Guest -
Login
Navigation
location:
>
Artenum OpenSource
>
ArtTk
>
Overview
Contextual Menu
ArtTk
Overview
Forum
License
Download
Developers
Sources
Bug Tracker
Maven site
Members
Managers
Members
Readers
Edit this menu
Resource Menu
Properties
Security
More actions...
----
Node Information
Create new resource
Delete this resource
Move this resource
Unbind this resource
----
List children
Go to parent
----
search from here
Overview
ArtTk is a Java/Swing based library offering an extensive toolkit for scientific and technical applications. ArtTk provides a set of widgets and functional modules like: - A set of helper classes allowing a dynamical definition of menu and toolbar from a simple XML-based descriptor, supporting text contents, tooltips, icons, action commands, etc… - A versatile and extensible multi-desktop component; - An extended Grid layout to simplify the development of advanced scientific applications; - A set of scientific and technical widgets like: -- A dynamical memory footprint monitor; -- Simple key-values based fields editors; -- A versatile color gradient editor -- … ArtTk has been made as light as possible in order to provide an efficient and simple solution for scientific and technical applications. ArtTk is used in several open-source and commercial projects like: - SPIS - Keridwen - Cassandra - BMGTools - … 1 Color gradient examples {image:../images/Gradients_png} In the example above, the color gradient at the top is directly read from the XML file below: {code}
{code} 1 GridBagPanel layout examples A GridBagPanel is a JPanel that implements methods facilitating the use of Swing GridBagLayout.\\ \\ A __HBox__ is a panel containing horizontally aligned components :\\ {code} GridBagPanel panel = new GridBagPanel.Builder("HBox").build(PanelType.HBOX); panel.addComponent(label1); panel.addComponent(button1); panel.addComponent(button2); {code} {image:../images/HBox_png} \\ A __VBox__ is a panel containing vertically aligned components :\\ {code} GridBagPanel panel = new GridBagPanel.Builder("VBox").build(PanelType.VBOX); panel.addComponent(label1); panel.addComponent(button1); panel.addComponent(button2); {code} {image:../images/VBox_png} \\ A __Grid__ is a panel containing components placed in a grid.\\ There are several ways to create a grid. The basic grid displayed at the top of the figure below could be built either by explicitly defining the component positions on the grid: {code} GridBagPanel grid1 = new GridBagPanel.Builder("Grid 1").build(PanelType.GRID); // First line grid1.position(0, 0).addComponent(label1); grid1.position(1, 0).addComponent(textField1); grid1.position(2, 0).addComponent(button1); // Second line grid1.position(0, 1).addComponent(label2); grid1.position(1, 1).addComponent(textField2); grid1.position(2, 1).addComponent(button2); {code} or by implicit construction (line by line): {code} GridBagPanel grid1 = new GridBagPanel.Builder("Grid 1").build(PanelType.GRID); // First line grid1.addComponent(label1); grid1.addComponent(textField1); grid1.addComponent(button1).newLine(); // Second line grid1.addComponent(label2); grid1.addComponent(textField2); grid1.addComponent(button2); {code} {image:../images/Grid_png} Of course, you can mix HBox , VBox and Grid components to obtain complex layouts: \\ {image:../images/GridBagPanel_Mix_png} 1 Logger example {image:../images/Logger_png} 1 Properties editor example {image:../images/PropertyEditor_png} 1 Multi-desktop example {image:../images/GeneralSample_png} 1.1 The Java source file {code} public class GeneralSample { public static void main(String\[\] args) throws Exception { // Frame initialisation JPanel toolBar = new JPanel(); toolBar.setLayout(new BoxLayout(toolBar, BoxLayout.PAGE_AXIS)); JFrame f = new JFrame("Test loader"); f.getContentPane().setLayout(new BorderLayout()); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(BorderLayout.NORTH, toolBar); // Sample of GUILoader usage GUILoader loader = new GUILoader(); loader.addActionListener(new PrintActionListener()); loader.load(GUILoader.class.getResource("/com/artenum/sample/Sample.xml").openStream()); // Add builded components in UI f.setJMenuBar((JMenuBar) loader.getBuildedObject("menuBar")); JToolBar bar = (JToolBar) loader.getBuildedObject("toolBar1"); bar.setAlignmentX(JPanel.LEFT_ALIGNMENT); toolBar.add(bar); bar = ((JToolBar) loader.getBuildedObject("toolBar2")); bar.setAlignmentX(JPanel.LEFT_ALIGNMENT); toolBar.add(bar); // Sample of desktop manager DesktopManager desktopManager = new DesktopManager(); desktopManager.addDesktop("Bureau 1"); desktopManager.addDesktop("Bureau 2"); desktopManager.addDesktop("Bureau 3"); // Add internal frame in multi-desktop JInternalFrame internalFrame = desktopManager.createMultiDesktopInternalFrame("Tutu", true, true, true, true); internalFrame.getContentPane().add(new JLabel("Hello tutu")); internalFrame.reshape(10, 10, 100, 100); internalFrame.setVisible(true); desktopManager.getCurrentDesktop().add(internalFrame); internalFrame = desktopManager.createMultiDesktopInternalFrame("Tata", true, true, true, true); internalFrame.getContentPane().add(new JLabel("Hello tata")); internalFrame.reshape(110, 10, 100, 100); internalFrame.setVisible(true); desktopManager.getDesktop(1).add(internalFrame); internalFrame = desktopManager.createMultiDesktopInternalFrame("Toto", true, true, true, true); internalFrame.getContentPane().add(new JLabel("Hello toto")); internalFrame.reshape(210, 10, 100, 100); internalFrame.setVisible(true); desktopManager.getDesktop("Bureau 3").add(internalFrame); f.getContentPane().add(BorderLayout.CENTER, desktopManager); // Finish the frame initialisation f.setSize(700, 500); f.setLocationRelativeTo(null); f.setVisible(true); } } {code} 1.1 The Xml file {code}
{code}
Last edited by Benoît Thiébault at Mar 5, 2010 7:53 AM -
Edit content
-
View source