Example usage for javax.swing AbstractAction AbstractAction

List of usage examples for javax.swing AbstractAction AbstractAction

Introduction

In this page you can find the example usage for javax.swing AbstractAction AbstractAction.

Prototype

public AbstractAction() 

Source Link

Document

Creates an Action .

Usage

From source file:jchrest.gui.VisualSearchPane.java

public VisualSearchPane(Chrest model, Scenes scenes) {
    super();/* w  w  w  .ja  v  a  2s  .  co  m*/

    _model = model;
    _scenes = scenes;
    //TODO: fix this when perceiver functionality working correctly.
    //_model.getPerceiver().setScene (_scenes.get (0));
    _model.setClocks(0);
    _sceneDisplay = new SceneDisplay(_scenes.get(0));
    _domainSelector = new JComboBox(new String[] { "Generic", "Chess" });
    _domainSelector.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            int index = _domainSelector.getSelectedIndex();
            if (index == 0) {
                _model.setDomain(new GenericDomain(_model, null, 3));
            } else { // if (index == 1) 
                //TODO: fix this when perceiver functionality working correctly.
                //_model.setDomain (new ChessDomain (_model));
            }
        }
    });

    JTabbedPane jtb = new JTabbedPane();
    jtb.addTab("Train", trainPanel());
    jtb.addTab("Recall", recallPanel());
    jtb.addTab("Log", logPanel());
    jtb.addTab("Analyse", analysePanel());

    setLayout(new BorderLayout());
    add(jtb);
}

From source file:be.vds.jtbdive.client.view.core.stats.StatPanel.java

private Component createHeader() {
    statWizardButton = new JButton(new AbstractAction() {

        private static final long serialVersionUID = -5345284505247399133L;

        @Override//from w  w  w  .j  a v a 2  s.c o  m
        public void actionPerformed(ActionEvent e) {
            StatWizard wizard = new StatWizard(logBookManagerFacade);
            statQueryObject = wizard.launchWizard();
            displayStatQueryObjectResult();
        }

    });
    statWizardButton.setIcon(UIAgent.getInstance().getIcon(UIAgent.ICON_STATISTICS_16));
    statWizardButton.setEnabled(false);

    JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT));
    p.setOpaque(false);
    p.add(statWizardButton);
    return p;
}

From source file:FrameKey.java

protected JRootPane createRootPane() {
    JRootPane rootPane = new JRootPane();
    KeyStroke stroke = KeyStroke.getKeyStroke("ESCAPE");
    Action actionListener = new AbstractAction() {
        public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);//w ww  .  j  a va 2 s  .  c  o  m
        }
    };
    InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(stroke, "ESCAPE");
    rootPane.getActionMap().put("ESCAPE", actionListener);

    return rootPane;
}

From source file:esmska.gui.AboutFrame.java

/** Creates new form AboutFrame */
public AboutFrame() {
    initComponents();/*from   w w w . j av  a 2s  .c  om*/
    closeButton.requestFocusInWindow();
    this.getRootPane().setDefaultButton(closeButton);

    //set window images
    ArrayList<Image> images = new ArrayList<Image>();
    images.add(Icons.get("about-16.png").getImage());
    images.add(Icons.get("about-22.png").getImage());
    images.add(Icons.get("about-32.png").getImage());
    images.add(Icons.get("about-48.png").getImage());
    setIconImages(images);

    //close on Ctrl+W
    String command = "close";
    getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
            KeyStroke.getKeyStroke(KeyEvent.VK_W, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
            command);
    getRootPane().getActionMap().put(command, new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            closeButtonActionPerformed(e);
        }
    });
}

From source file:org.codinjutsu.tools.mongo.view.MongoEditionPanel.java

public MongoEditionPanel init(final MongoPanel.MongoDocumentOperations mongoDocumentOperations,
        final MongoResultPanel.ActionCallback actionCallback) {

    cancelButton.addActionListener(new AbstractAction() {
        @Override/*  w  ww .  j a v  a  2 s. c o  m*/
        public void actionPerformed(ActionEvent actionEvent) {
            actionCallback.onOperationCancelled("Modification canceled...");
        }
    });

    saveButton.addActionListener(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            try {
                mongoDocumentOperations.updateMongoDocument(buildMongoDocument());
                actionCallback.onOperationSuccess("Document saved...");
            } catch (Exception exception) {
                actionCallback.onOperationFailure(exception);
            }
        }
    });

    deleteButton.addActionListener(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            try {
                mongoDocumentOperations.deleteMongoDocument(getDocumentId());
                actionCallback.onOperationSuccess("Document deleted...");
            } catch (Exception exception) {
                actionCallback.onOperationFailure(exception);
            }
        }
    });

    return this;
}

From source file:com.hammurapi.jcapture.CaptureFrame.java

public CaptureFrame(final AbstractCaptureApplet applet) throws Exception {
    super("Screen capture");
    setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("camera.png")));

    setUndecorated(true);//from w  ww  .ja v a  2s  .c  o  m

    Translucener.makeFrameTranslucent(this);

    setAlwaysOnTop(true);
    this.applet = applet;
    captureConfig = new CaptureConfig();
    captureConfig.load(applet.loadConfig());
    captureConfig.setBackgroundProcessor(applet.getBackgroundProcessor());

    //--- GUI construction ---

    capturePanel = new JPanel();

    final JLabel dimensionsLabel = new JLabel("");
    capturePanel.add(dimensionsLabel, BorderLayout.CENTER);

    capturePanel.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            super.componentResized(e);
            dimensionsLabel.setText(e.getComponent().getWidth() + " x " + e.getComponent().getHeight());
        }
    });

    JButton captureButton = new JButton(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Rectangle bounds = capturePanel.getBounds();
            Point loc = bounds.getLocation();
            SwingUtilities.convertPointToScreen(loc, capturePanel);
            bounds.setLocation(loc);
            Properties props = captureConfig.setRecordingRectangle(bounds);
            if (props != null) {
                getApplet().storeConfig(props);
            }
            capturing.set(true);
            setVisible(false);
        }

    });
    captureButton.setText("Capture");
    captureButton.setToolTipText("Create a snapshot of the screen");
    capturePanel.add(captureButton, BorderLayout.CENTER);

    recordButton = new JButton(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Rectangle bounds = capturePanel.getBounds();
            Point loc = bounds.getLocation();
            SwingUtilities.convertPointToScreen(loc, capturePanel);
            bounds.setLocation(loc);
            Properties props = captureConfig.setRecordingRectangle(bounds);
            if (props != null) {
                getApplet().storeConfig(props);
            }
            recording.set(true);
            setVisible(false);
        }

    });
    recordButton.setText("Record");
    setRecordButtonState();
    capturePanel.add(recordButton, BorderLayout.CENTER);

    JButton optionsButton = new JButton(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            new CaptureOptionsDialog(CaptureFrame.this).setVisible(true);
        }

    });
    optionsButton.setText("Options");
    capturePanel.add(optionsButton, BorderLayout.CENTER);

    JButton cancelButton = new JButton(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            CaptureFrame.this.setVisible(false);
        }

    });
    cancelButton.setText("Cancel");
    capturePanel.add(cancelButton, BorderLayout.CENTER);

    getContentPane().add(capturePanel, BorderLayout.CENTER);

    capturePanel.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false));

    if (captureConfig.getRecordingRectangle() == null) {
        setSize(400, 300);
        setLocationRelativeTo(null);
    } else {
        setBounds(captureConfig.getRecordingRectangle());
    }

    Insets dragInsets = new Insets(5, 5, 5, 5);
    new ComponentResizer(dragInsets, this);

    ComponentMover cm = new ComponentMover();
    cm.registerComponent(this);
    cm.setDragInsets(dragInsets);

    addComponentListener(new ComponentListener() {

        @Override
        public void componentShown(ComponentEvent e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void componentResized(ComponentEvent e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void componentMoved(ComponentEvent e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void componentHidden(ComponentEvent e) {
            if (capturing.get()) {
                capturing.set(false);
                try {
                    capture();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            } else if (recording.get()) {
                recording.set(false);
                record();
            }
        }
    });

}

From source file:com.moneydance.modules.features.importlist.table.AbstractEditor.java

public final void registerKeyboardShortcut(final JComponent jComponent) {
    Validate.notNull(jComponent, "jComponent must not be null");
    if (this.getKeyStroke() == null) {
        return;/*from  w  ww . j a va  2  s  .c o m*/
    }

    final Action action = new AbstractAction() {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(final ActionEvent actionEvent) {
            ActionListener actionListener = AbstractEditor.this.getActionListener(0);
            actionListener.actionPerformed(actionEvent);
        }
    };

    final String actionMapKey = this.getClass().getName(); // unique
    jComponent.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(this.getKeyStroke(), actionMapKey);
    jComponent.getActionMap().put(actionMapKey, action);
}

From source file:inflor.core.plots.FCSChartPanel.java

public FCSChartPanel(JFreeChart chart, ChartSpec spec, FCSFrame data, TransformSet transforms) {
    super(chart);
    this.data = data;
    this.spec = spec;
    this.transformSet = transforms;

    getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("DELETE"),
            DELETE_ANNOTATIONS_KEY);/*from w w w. ja  va2  s.c  o m*/
    getActionMap().put(DELETE_ANNOTATIONS_KEY, new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            deleteSelectedAnnotations();
        }
    });
    Range xRange = this.getChart().getXYPlot().getDomainAxis().getRange();
    xHandleSize = (xRange.getUpperBound() - xRange.getLowerBound()) / 100;
    Range yRange = this.getChart().getXYPlot().getDomainAxis().getRange();
    yHandleSize = (yRange.getUpperBound() - yRange.getLowerBound()) / 100;
}

From source file:org.cds06.speleograph.graph.DateAxisEditor.java

public DateAxisEditor(DateAxis dateAxis) {
    super(SpeleoGraphApp.getInstance(), true);
    this.axis = dateAxis;
    this.setTitle(I18nSupport.translate("graph.dateAxisEditor"));
    JPanel panel = new JPanel();
    panel.setLayout(//from   w w w.ja va2 s  .  c om
            new FormLayout("r:p,4dlu,p:grow,4dlu", "p:grow,p,4dlu:grow,p,4dlu:grow,p,4dlu:grow,p,p:grow"));
    CellConstraints cc = new CellConstraints();
    panel.add(new JLabel("Format :"), cc.xy(1, 2));
    panel.add(dateSelector, cc.xy(3, 2));
    panel.add(new JLabel("Date dbut :"), cc.xy(1, 4));
    panel.add(minDate, cc.xy(3, 4));
    panel.add(new JLabel("Date fin :"), cc.xy(1, 6));
    panel.add(maxDate, cc.xy(3, 6));

    ButtonBarBuilder barBuilder = new ButtonBarBuilder();
    barBuilder.addGlue();

    //Cancel button
    barBuilder.addButton(new AbstractAction() {

        {
            putValue(NAME, I18nSupport.translate("cancel"));
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
        }
    });

    //Ok button
    barBuilder.addButton(new AbstractAction() {

        {
            putValue(NAME, I18nSupport.translate("ok"));
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            axis.setDateFormatOverride((DateFormat) dateSelector.getSelectedItem());
            axis.setMinimumDate(minDate.getDate());
            axis.setMaximumDate(maxDate.getDate());
            setVisible(false);
        }
    });

    panel.add(barBuilder.build(), cc.xyw(1, 8, 3));

    minDate.setDate(dateAxis.getMinimumDate());
    maxDate.setDate(dateAxis.getMaximumDate());
    if (dateAxis.getDateFormatOverride() != null
            && dateAxis.getDateFormatOverride() instanceof HumanSimpleDateFormat) {
        dateSelector.setSelectedItem(dateAxis.getDateFormatOverride());
    }

    setContentPane(panel);
    panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    setSize(panel.getPreferredSize().width + 100, panel.getPreferredSize().height + 100);

}

From source file:com.aw.swing.mvp.JDialogView.java

private void initializeLayout() {
    if (!(vsr instanceof JDialog)) {
        UserInfo ui = pst.getApplicationUser();
        String userName = ui.getUsername();
        viewLayout = new MainFormLayout(getTitle(), "system1".equals(userName) ? " " : userName);

        JPanel formPanel = (JPanel) AttributeAccessor.get(vsr, "pnlMain");
        formPanel.putClientProperty("pnlMain", true);

        /*//from ww w.ja va 2 s  . c  om
                    JPanel footerPanel = (JPanel) AttributeAccessor.get(vsr, "footerPanel");
                    Component[]  components=footerPanel.getComponents();
                    for(int i=0;i<components.length;i++){
        if(components[i] instanceof JLabel){
            ((JLabel)components[i]).setBackground(new Color(-13395480));
            ((JLabel)components[i]).setOpaque(true);
            ((JLabel)components[i]).setForeground(new Color(-1));
        }
                    }
        */

        viewLayout.contentPanel.add(formPanel, BorderLayout.CENTER);

        AbstractAction aa = new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
                if (logger.isDebugEnabled())
                    logger.debug("Closing view for " + pst);
                pst.closeView();
            }
        };

        if (pst instanceof FindPresenter || pst.isShowCloseButton()) {
            logger.info("Close button added to view");
            //                ((HeaderPanel) viewLayout.headerPanel).createCloseButton(aa);
        }
        addUserInfo();
    }
}