convert Swing Actions - Java Swing

Java examples for Swing:Action

Description

convert Swing Actions

Demo Code


import javax.swing.Action;

public class Main{
    public static void main(String[] argv) throws Exception{
        Object[] uobj = new String[]{"1","abc","level",null,"java2s.com","asdf 123"};
        System.out.println(java.util.Arrays.toString(convertActions(uobj)));
    }//from w  w w  . ja v  a 2 s  .c  o  m
    public static Action[] convertActions(Object[] uobj) {

        Action[] uact = new Action[uobj.length];
        for (int i = 0; i < uobj.length; i++) {
            if (uobj[i] == null)
                uact[i] = null; // Handle the 
            if (uobj[i] instanceof Action)
                uact[i] = (Action) uobj[i];
            if (uobj[i] instanceof ActionInformationNew) {
                ActionInformationNew command = (ActionInformationNew) uobj[i];
                if (command.getCommandType() == ActionInformationNew.GENERAL) {
                    uact[i] = new TopObjectActionNew(command, true);
                }
                //else if (command.getCommandType() == ActionInformationNew.EXPLORER) uact[i] = SystemAction.get(OpenLocalExplorerAction.class);
                //else if (command.getCommandType() == ActionInformationNew.PROPERTIES) uact[i] = SystemAction.get(PropertiesAction.class);
            }
        }
        return uact;
    }
}

Related Tutorials