The Swing Graphical User Interface

The only currently available gui-system is Swing (for Java)

I implemented the windows with JFrames; the groups are implemented with Box:es... The invisible objects are implemented with methods (each invisible object, with for now only an integer input port, is a method that takes an integer as argument.) The behaviour itself of the swing implementation is the one that is specified in the guiBlock section (to which all gui-system classes are supposed to comply)

You find below the Amool code for @guiBlock (which currently is Java only), and @swing. You can find something more readable in the API reference :-)

In the next section (putting all together), I'll explain how you can actually code something with these classes. Please note however that the complete specification is temporary, as it does not yet fulfill my expectations. So I might rewrite large parts of it (which might make earlier codes uncompatible)

However, the actual structure should remain

The Implementation Of @guiBlock


&=super @javaClass && @super

&+import java.util.* &&

&+methods &=super @'program.method && @super
  &=name attachTo &&
  &+arguments @'guiBlock.parent.name parent &&
  &=code this.parent = parent;
        @forAll( @parent.owner.startup &, @lf         &, @startup &)
        @forAll( @parent.owner.init &, @lf         &, @init &)
&&
&&

&+methods &=super @'program.method && @super
  &=name removeFrom &&
  &+arguments @'guiBlock.parent.name parent &&
  &=code @forAll( @parent.owner.exit &, @lf         &, @exit &)
        @forAll( @parent.owner.finish &, @lf         &, @finish &)
&&
&&

&+parent.methods &=super @'program.method && @super
  &=name add @% @parent.owner.name &&
  &=return @parent.owner.name &&
  &=code @parent.owner.name created = new @parent.owner.name @% ();
        inner @% @parent.owner.name @% .addElement(created);
        created.attachTo(this);
        return created; &&
&&

&+parent.methods &=super @'program.method && @super
  &=name remove @% @parent.owner.name &&
  &+arguments @parent.owner.name tbr &&
  &=code tbr.removeFrom(this);
        inner @% @parent.owner.name @% .removeElement(tbr); &&
&&

&+parent.finish
for (Enumeration en = inner @% @owner.name @% .elements();en.hasMoreElements();)
            (( @% @owner.name @% )en.nextElement()).removeFrom(this);
        inner @% @owner.name @% .removeAllElements();
&&

&+variables @parent.parent.name parent; &&

&=vectorName inner @% @parent.name &&
&+parent.variables Vector @owner.vectorName = new Vector(); &&

&=stepUp( @following &)
  &=connect( @src &, @tag &)
@parent.following.connect( @src &, @tag @% parent. &)
  &&
  &=unconnect( @src &, @tag &)
@parent.following.unconnect( @src &, @tag @% parent. &)
  &&
  &=copyFrom( @src &, @tag &)
@parent.following.copyFrom( @src &, @tag @% parent. &)
  &&
&&

&=stepDown( @following &)
  &=generic
for (Enumeration en = @tag @% @'guiBlock.vectorName @% .elements() ; en.hasMoreElements() ;) {
                @'guiBlock.name p = ( @% @'guiBlock.name @% ) en.nextElement();
                @action( p. &)
                }
&&
  &=connect( @src &, @tag &) &=super @parent.generic && @super
    &=action( @tag &) @'stepDown.following.connect( @parent.src &, @tag &)
&& &&
  &=unconnect( @src &, @tag &) &=super @parent.generic && @super
    &=action( @tag &) @'stepDown.following.unconnect( @parent.src &, @tag &)
&& &&
  &=copyFrom( @src &, @tag &) &=super @parent.generic && @super
    &=action( @tag &) @'stepDown.following.copyFrom( @parent.src &, @tag &)
&& &&
&&
&=!gadget
  &=attachedTo @'gadget.parent &&
  &+'guiBlock.variables @owner.clsid @owner.name = @owner.alloc ; &&
  &+'guiBlock.startup @owner.attachedTo.connect( @owner.name &) &&
  &+'guiBlock.finish  @owner.attachedTo.unconnect( @owner.name &) &&
&&

&=!sMethod
&+'guiBlock.methods @super
 &=super @'guiBlock.method &&
 &=name @parent.owner.name &&
 &=arguments int value &&
 &=code @parent.owner.code &&
&&
&=copyFrom( @src &, @tag &)
@tag @% @parent.name @% ( @src );
&&
&&

The Implementation of @swing


&=super @guiBlock && @super

&+import java.awt.* &&
&+import java.awt.event.* &&
&+import javax.swing.* &&
&+import javax.swing.event.* &&

&+actions.parent.implements ActionListener &&
&+changes.parent.implements ChangeListener &&

&+actions.parent.methods &=super @parent.method && @super
  &=name actionPerformed &&
  &+arguments ActionEvent e &&
  &=code @forAll( @'guiBlock.actions &, &, @actions &) &&
&&

&+changes.parent.methods &=super @parent.method && @super
  &=name stateChanged &&
  &+arguments ChangeEvent e &&
  &=code @forAll( @'guiBlock.changes &, &, @changes &) &&
&&

&+startup @if( @parent.needSize &,
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); &)
&&

&=!window

   &+'guiBlock.variables JFrame @owner.name = new JFrame( @owner.title ); &&

   &+'guiBlock.startup @owner.name @% .setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); &&

   &=access @owner.name @% .getContentPane() &&

   &+'guiBlock.needSize true &&
   &+'guiBlock.init @owner.name @% .pack();
        @owner.name @% .setLocation((screenSize.width - @owner.name @% .getSize().width)/2,
            (screenSize.height - @owner.name @% .getSize().height)/2);
        @owner.name @% .setVisible(true); &&
   &+'guiBlock.exit @owner.name @% .setVisible(false); &&

   &=connect( @src &, @tag &)
@tag @% @'window.name @% .getContentPane().add( @src );
   &&
   &=unconnect( @src &, @tag &)
@tag @% @'window.name @% .getContentPane().remove( @src );
   &&
&&

&=!group( @axis &) &=super @'guiBlock.gadget &&
   &=clsid Box &&
   &=alloc new Box(BoxLayout. @% @parent.axis @% _AXIS) &&
   &=connect( @src &, @tag &)
@tag @% @'gadget.name @% .add( @src );
   &&
   &=unconnect( @src &, @tag &)
@tag @% @'gadget.name @% .remove( @src );
   &&
&&

&=!hgroup &=super @'guiBlock.group( X &) &&
&&

&=!vgroup &=super @'guiBlock.group( Y &) &&
&&

&=!label &=super @'guiBlock.gadget &&
   &=clsid JLabel &&
   &=alloc new JLabel( @% @owner.text @% ) &&
   &=copyFrom( @src &, @tag &)
@tag @% @owner.name @% .setText( @src + "" );
   &&
&&
&=!textField &=super @'guiBlock.gadget &&
   &=clsid JTextField &&
   &=alloc new JTextField( @% @parent.text @% ) &&
   &+'guiBlock.startup @if( @equals( @owner.action &) &, &,
@owner.name @% .addActionListener(this); &) &&
   &+'guiBlock.actions @if( @equals( @owner.action &) &, &,
if (e.getSource() == @owner.name @% ) {
@forAll( @owner.action &, &,
            @action
 &)
        }
&) &&
&&
&=!button &=super @'guiBlock.gadget &&
   &=clsid JButton &&
   &=alloc new JButton( @% @parent.text @% ) &&
   &+'guiBlock.startup @if( @equals( @owner.action &) &, &,
@owner.name @% .addActionListener(this); &) &&
   &+'guiBlock.actions @if( @equals( @owner.action &) &, &,
if (e.getSource() == @owner.name @% ) {
@forAll( @owner.action &, &,
            @action
 &)
        }
&) &&
&&
&=!check &=super @'guiBlock.gadget &&
   &=clsid JCheckBox &&
   &=alloc new JCheckBox( @% @parent.text @% ) &&
&&
&=!slide &=super @'guiBlock.gadget &&
   &=clsid JSlider &&
   &=alloc new JSlider() &&
   &+'guiBlock.startup
@owner.name @% .addChangeListener(this); &&
   &+'guiBlock.changes
if (e.getSource() == @owner.name @% ) {
            if (! @% @owner.name @% Notifying) {
                @owner.name @% Notifying = true;
@forAll( @owner.speakTo &, &,
                @speakTo.copyFrom( @owner.name @% .getValue() &)
 &)
                @owner.name @% Notifying = false;
            }
        }
  &&
  &+'guiBlock.variables 
    protected boolean @owner.name @% Notifying = false;
  &&

  &=copyFrom( @X &, @tag &) @tag @% @owner.name @% .setValue( @% @X @% ); &&

&&


Maxime Gamboni
Last modified: Fri Jun 29 20:21:41 MET DST 2001