Example usage for javax.swing Action Action

List of usage examples for javax.swing Action Action

Introduction

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

Prototype

Action

Source Link

Usage

From source file:ext.scrollablepopupmenu.TestXCheckedButton.java

/**
 * Test method for.//from   ww  w . j  ava 2s . c o  m
 *
 * {@link ext.scrollablepopupmenu.XCheckedButton#XCheckedButton(javax.swing.Action)}
 * .
 */
public final void testXCheckedButtonAction() {
    new XCheckedButton(new Action() {
        @Override
        public void addPropertyChangeListener(PropertyChangeListener listener) {
        }

        @Override
        public Object getValue(String key) {
            return null;
        }

        @Override
        public boolean isEnabled() {
            return false;
        }

        @Override
        public void putValue(String key, Object value) {
        }

        @Override
        public void removePropertyChangeListener(PropertyChangeListener listener) {
        }

        @Override
        public void setEnabled(boolean b) {
        }

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

From source file:savant.view.swing.DockableFrameFactory.java

public static Frame createTrackFrame(DataFormat df) {

    final Frame frame = new Frame(df);

    frame.setAvailableButtons(/*from   w w  w  .  ja va  2  s .  c  o  m*/
            DockableFrame.BUTTON_AUTOHIDE | DockableFrame.BUTTON_MAXIMIZE | DockableFrame.BUTTON_CLOSE);

    frame.setSlidingAutohide(false);
    frame.setInitMode(DockContext.STATE_FRAMEDOCKED);
    frame.setInitSide(DockContext.DOCK_SIDE_NORTH);

    frame.add(new JPanel());

    frame.setCloseAction(new Action() {
        private boolean isEnabled = true;
        private Map<String, Object> map = new HashMap<String, Object>();

        @Override
        public void actionPerformed(ActionEvent e) {
            FrameController.getInstance().closeFrame(frame, true);
        }

        @Override
        public Object getValue(String key) {
            if (key.equals(Action.NAME)) {
                return "Close";
            } else {
                return map.get(key);
            }
        }

        @Override
        public void putValue(String key, Object value) {
            map.put(key, value);
        }

        @Override
        public void setEnabled(boolean b) {
            this.isEnabled = b;
        }

        @Override
        public boolean isEnabled() {
            return isEnabled;
        }

        @Override
        public void addPropertyChangeListener(PropertyChangeListener listener) {
        }

        @Override
        public void removePropertyChangeListener(PropertyChangeListener listener) {
        }
    });

    // TODO: this seems cyclical. What's going on here?
    JPanel panel = (JPanel) frame.getContentPane();
    panel.setLayout(new BorderLayout());
    panel.add(frame.getFrameLandscape());
    return frame;
}