Gola


A Graphical Layout Editor for Java Swing/AWT


  The following example is available as ExampleDialog in the Gola distribution.

  View the sequence of images of the Gola GUI as the user builds the simple GUI shown below.

   The following code was generated by Gola for the simple GUI shown below:




import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.border.*;
import javax.swing.event.*;
import pagelayout.*;
import pagelayout.util.*;
import static pagelayout.EasyCell.*;



/* 
   Generated code.
   ---------------
   This class is best used in applications by 
   extending it, and overriding the method 
   'decorateComponents' in the subclass.
   All the EventListeners should be added 
   to the various components in the over-ridden
   method 'docorateComponents'.


   Once the subclass has been appropriately
   defined and compiled, it can be used by 
   constructing a object of the derived subclass
   and calling the 'createGUI(Container c)'
   method of the object.

   For an example, see the 'testGUI' method of 
   of this class.

   A quick test without the need to write any code
   can be performed by compiling and 
   running this class by the following shell commands

> javac -classpath pagelayoutX.XX.jar;. ExampleDialog.java
> java -classpath pagelayoutX.XX.jar;. ExampleDialog

   Here 'pagelayoutX.XX.jar is the appropriate 
   jar file for the pagelayout layout manager 
   of version 1.14 or later.
*/
public class ExampleDialog
{
  protected JLabel name;
  protected JTextField nameEditor;
  protected JLabel email;
  protected JTextField emailEditor;
  protected JButton ok;
  protected JButton cancel;
  protected Row row1;
  protected CellGrid root;
/* 
   This is just a convenience method 
   to create the object ExampleDialog.
*/
  public static ExampleDialog createGUIObject()
  {
     return new ExampleDialog();
  }
/* 
   Normally this  method does not need 
   to be modified.
*/
  protected void createComponents()
  {

     name = new javax.swing.JLabel();
     name.setText("Name");

     nameEditor = new javax.swing.JTextField();
     nameEditor.setText("");
     setDimensions(nameEditor, 17, 6, 25, 32767, 25, 193, 25);

     email = new javax.swing.JLabel();
     email.setText("Email");

     emailEditor = new javax.swing.JTextField();
     emailEditor.setText("");
     setDimensions(emailEditor, 17, 6, 25, 32767, 25, 193, 25);

     ok = new javax.swing.JButton();
     ok.setText("OK");

     cancel = new javax.swing.JButton();
     cancel.setText("Cancel");

     decorateComponents();

  }
/* 
   Normally this  method does not need 
   to be modified.
*/
  protected void createCells()
  {
     row1 = row(right, none,  ok,  cancel);

     root = grid(name, nameEditor, eol(), 
                 email, emailEditor, eol(), 
                 row1, hspan());


     setConstraints();

  }

/* 
   The following 'dummy action' methods should
   to be modified for the application.
*/
/* 
   A dummy action for emailEditor.
*/
  public void emailEditorTextEntered(ActionEvent e)
  {
     System.out.println("Text has been entered in emailEditor.");
  }

/* 
   A dummy action for nameEditor.
*/
  public void nameEditorTextEntered(ActionEvent e)
  {
     System.out.println("Text has been entered in nameEditor.");
  }

/* 
   A dummy action for cancel.
*/
  public void cancelClicked(ActionEvent e)
  {
     System.out.println("The button cancel has been clicked.");
  }

/* 
   A dummy action for ok.
*/
  public void okClicked(ActionEvent e)
  {
     System.out.println("The button ok has been clicked.");
  }

/* 
   Normally this  method does not need 
   to be modified.
*/
  private void setConstraints()
  {
     root.linkWidth( cancel,new Component[]{
                                       ok },
                                       new double[]{
                                         1.00 });
  }
/* 
   Override this  method in a subclass 
   to add your own event listeners.
   Here actionListeners have been added to each 
   button to print a message when the button 
   is clicked.
*/
  protected void decorateComponents()
  {

     emailEditor.addActionListener(
		new ActionListener(){
		  public void actionPerformed(ActionEvent e){
			 emailEditorTextEntered(e);
		  }
		});

     nameEditor.addActionListener(
		new ActionListener(){
		  public void actionPerformed(ActionEvent e){
			 nameEditorTextEntered(e);
		  }
		});

     cancel.addActionListener(
		new ActionListener(){
		  public void actionPerformed(ActionEvent e){
			 cancelClicked(e);
		  }
		});

     ok.addActionListener(
		new ActionListener(){
		  public void actionPerformed(ActionEvent e){
			 okClicked(e);
		  }
		});

  }
/* 
   This method should be called for creating
   the layout for a given container.
*/
  public void createGUI(Container container)
  {
     createComponents();
     createCells();
     root.createLayout(container);
  }
/* 
   This method may be called for testing the 
   generated code. It should not require
   the generated code to be modified in any way.
*/
  public static void testGUI()
  {
     JFrame f=new JFrame();
     f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     createGUIObject().createGUI(f.getContentPane());
     f.pack();
     Dimension d=f.getPreferredSize();
     f.setSize(new Dimension(d.width,d.height));
     f.setVisible(true);
  }
/* 
   This calls the method for testing the 
   generated code. It should not require
   the generated code to be modified in any way.
*/
  public static void main(String[] args)
  {
     SwingUtilities.invokeLater(
          new Runnable(){public void run(){testGUI();}});
  }


}