public ResourceReference<GmObject> getApplies() {
   if (applies.getValue() >= 0) {
     ResourceReference<GmObject> sel = appliesObject.getSelected();
     if (sel != null) return sel;
     return act.getAppliesTo();
   }
   if (applies.getValue() == -1) return GmObject.OBJECT_SELF;
   if (applies.getValue() == -2) return GmObject.OBJECT_OTHER;
   return null;
 }
 @SuppressWarnings({"unchecked", "rawtypes"})
 public void discard() {
   if (editor instanceof JTextField) {
     ((JTextField) editor).setText(arg.getVal());
   } else if (editor instanceof JComboBox) {
     ((JComboBox) editor).setSelectedIndex(Integer.parseInt(arg.getVal()));
   } else if (editor instanceof ColorSelect) {
     Color c = Util.convertGmColor(Integer.parseInt(arg.getVal()));
     ((ColorSelect) editor).setSelectedColor(c);
   } else if (editor instanceof ResourceMenu) {
     try {
       ((ResourceMenu) editor).setSelected(arg.getRes());
     } catch (NumberFormatException nfe) {
     }
   }
 }
  // Must be delegated through ActionFrame(Action)
  private ActionFrame(Action a, LibAction la) {
    super(la.description, false);
    if (la.parent == null) setTitle(Messages.getString("Action.UNKNOWN")); // $NON-NLS-1$
    if (la.actImage != null)
      setFrameIcon(new ImageIcon(la.actImage.getScaledInstance(16, 16, Image.SCALE_SMOOTH)));
    String s;
    ResourceReference<GmObject> at = a.getAppliesTo();
    if (at == GmObject.OBJECT_SELF) s = Messages.getString("ActionFrame.SELF"); // $NON-NLS-1$
    else s = Messages.getString("ActionFrame.OTHER"); // $NON-NLS-1$
    appliesObject = new ResourceMenu<GmObject>(Resource.Kind.OBJECT, s, false, 100);
    appliesObject.setEnabled(GmObject.refAsInt(at) >= 0);
    appliesObject.setOpaque(false);
    appliesObject.setSelected(at);
    act = a;

    appliesPanel = new JPanel();
    appliesPanel.setOpaque(false);
    appliesPanel.setLayout(new GridBagLayout());

    GridBagConstraints gbc;
    applies = new IndexButtonGroup(3, true, false);
    JRadioButton button = new JRadioButton(Messages.getString("ActionFrame.SELF")); // $NON-NLS-1$
    button.setOpaque(false);
    applies.add(button, -1);
    gbc = new GridBagConstraints();
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    appliesPanel.add(button, gbc);
    button = new JRadioButton(Messages.getString("ActionFrame.OTHER")); // $NON-NLS-1$
    button.setOpaque(false);
    applies.add(button, -2);
    gbc = new GridBagConstraints();
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    appliesPanel.add(button, gbc);
    button = new JRadioButton(Messages.getString("ActionFrame.OBJECT")); // $NON-NLS-1$
    button.setHorizontalAlignment(JRadioButton.LEFT);
    button.setOpaque(false);
    button.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            boolean sel = ((JRadioButton) e.getSource()).isSelected();
            appliesObject.setEnabled(sel);
          }
        });
    applies.add(button, 0);
    gbc = new GridBagConstraints();
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    appliesPanel.add(button, gbc);
    gbc = new GridBagConstraints();
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1.0;
    gbc.insets = new Insets(0, 2, 0, 6);
    appliesPanel.add(appliesObject, gbc);
    applies.setValue(Math.min(GmObject.refAsInt(at), 0));

    if (la.interfaceKind == LibAction.INTERFACE_CODE) {
      setSize(600, 400);
      setClosable(true);
      setMaximizable(true);
      setResizable(true);
      setIconifiable(true);

      tool = new JToolBar();
      tool.setFloatable(false);
      tool.setAlignmentX(0);
      save = new JButton(LGM.getIconForKey("ActionFrame.SAVE")); // $NON-NLS-1$
      save.addActionListener(this);
      //			add(save);
      tool.add(save);
      tool.addSeparator();

      code = new GMLTextArea(a.getArguments().get(0).getVal());
      code.addEditorButtons(tool);

      tool.addSeparator();
      tool.add(new JLabel(Messages.getString("ActionFrame.APPLIES"))); // $NON-NLS-1$
      tool.add(appliesPanel);

      status = new JPanel(new FlowLayout());
      status.setLayout(new BoxLayout(status, BoxLayout.X_AXIS));
      status.setMaximumSize(new Dimension(Integer.MAX_VALUE, 11));
      final JLabel caretPos =
          new JLabel((code.getCaretLine() + 1) + ":" + (code.getCaretColumn() + 1));
      status.add(caretPos);
      code.addCaretListener(
          new CaretListener() {
            public void caretUpdate(CaretEvent e) {
              caretPos.setText((code.getCaretLine() + 1) + ":" + (code.getCaretColumn() + 1));
            }
          });

      add(tool, BorderLayout.NORTH);
      add(code, BorderLayout.CENTER);
      add(status, BorderLayout.SOUTH);

      setFocusTraversalPolicy(new TextAreaFocusTraversalPolicy(code));
      appliesPanel.setLayout(new BoxLayout(appliesPanel, BoxLayout.LINE_AXIS));
    } else makeArgumentPane(a, la);
    pack();
    repaint();
    SubframeInformer.fireSubframeAppear(this);
  }