Hi,

This new method seems to be step to rigth direction. Great.
Is there method to get reference to created action so that I can enable/disable
the menu/toolbar/popupmenu (or any AbstarctButton bound to action).
Annother problem maid be setting common icon and acceleartor.
I can't see how to set these?

My suggestion is follows, is it possible to enhance the interface like this?

XUL -----------------------------------------------------

<frame ....>
     <action id="action-new" text="New" icon="/icons/new.gif" mnemonic="VK_N"
ToolTipText="New" enabled="true" actionClass="newAction"  />
     <action is="action-open" text="Open" icon="/icons/open.gif" mnemonic="VK_O"
ToolTipText="Open" enabled="true" actionClass="openAction" />
     <menubar>
          <menu text="File">
                    <menuitem use="action-new"/>
                    <menuitem use="action-open"/>
          </menu>
     </menubar>
     <panel layout="borderlayout" constraints="BorderLayout.NORTH">
          <toolbar floatable="true" borderPainted="true"
orientation="HORIZONTAL">
                    <button use="action-new" />
                    <button use="action-open" />
          </toolbar>
     </panel>
     ....
     <popupmenu>
                    <menuitem use="action-new"/>
                    <menuitem use="action-open"/>
     </popupmenu>
     ...
</frame>

END OF XUL -----------------------------------------------------


JAVA ------------------------------------------------------

package org.swixml.examples;

import org.swixml.SwingEngine;

import javax.swing.*;
import javax.swing.Action;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;

public class Action extends SwingEngine {

  private String msg = "Clicked";

  public AbstractAction newAction = new AbstractAction() {
    public void actionPerformed(ActionEvent e) {
      System.out.println( "newAction" );
     ((Action) find("action-open")).setEnabled(false); // silly example
    }
  };

  public AbstractAction openAction = new AbstractAction() {
    public void actionPerformed(ActionEvent e) {
      System.out.println( "openAction" );
    }
  };

  private ActionEx() {
    try {
      this.render( new URL(
"file:///C:/work/swixex/classes/org/swixml/examples/suggestion.xml" ) );
    } catch (Exception e) {
      e.printStackTrace();
    }
    this.getRootComponent().setVisible( true );
  }

  public static void main(String[] args) {
    new ActionEx();

  }
}
END OF JAVA ---------------------------------------

What you think about this?

//Jarmo



Reply via email to