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(String name) 

Source Link

Document

Creates an Action with the specified name.

Usage

From source file:com.opendoorlogistics.studio.AppFrame.java

private JMenu initHelpMenu() {
    JMenu mnHelp = new JMenu("Help");
    mnHelp.setMnemonic('H');

    mnHelp.add(initGotoWebsiteAction());

    mnHelp.add(new AbstractAction("About ODL Studio") {

        @Override/*from   w  ww .  ja  va 2 s.  com*/
        public void actionPerformed(ActionEvent e) {
            final AboutBoxDialog dlg = new AboutBoxDialog(AppFrame.this, false);
            dlg.setLocationRelativeTo(AppFrame.this);
            dlg.setVisible(true);
        }
    });

    mnHelp.add(new AbstractAction("List of data adapter functions") {

        @Override
        public void actionPerformed(ActionEvent e) {
            addInternalFrame(FunctionsListPanel.createFrame(), FramePlacement.AUTOMATIC);
        }
    });

    mnHelp.add(new AbstractAction("List of 3rd party data & libraries") {

        @Override
        public void actionPerformed(ActionEvent e) {
            final AboutBoxDialog dlg = new AboutBoxDialog(AppFrame.this, true);
            dlg.setTitle("3rd party data & libs used in ODL Studio");
            dlg.setLocationRelativeTo(AppFrame.this);
            dlg.setVisible(true);
        }
    });
    return mnHelp;
}

From source file:edu.ku.brc.af.ui.forms.ViewFactory.java

/**
 * @param destObj/*from ww  w.  j  av  a  2s  .c  o  m*/
 * @param textField
 */
public static void addTextFieldPopup(final GetSetValueIFace destObj, final JTextField textField,
        final boolean doAddDate) {
    if (textField != null) {
        JPopupMenu popupMenu = new JPopupMenu();

        if (doAddDate) {
            AbstractAction aa = new AbstractAction("Clear It") {

                @Override
                public void actionPerformed(ActionEvent e) {
                    DateWrapper scrDateFormat = AppPrefsCache.getDateWrapper("ui", "formatting",
                            "scrdateformat");
                    if (scrDateFormat != null) {
                        destObj.setValue(scrDateFormat.format(Calendar.getInstance()), "");
                    } else {
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                        destObj.setValue(sdf.format(Calendar.getInstance()), "");
                    }
                }
            };

            UIHelper.createLocalizedMenuItem(popupMenu, "ViewFactory.CURR_DATE", "", "", true, aa);

            KeyStroke ctrlShiftT = KeyStroke.getKeyStroke(KeyEvent.VK_T,
                    InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK);
            textField.getInputMap().put(ctrlShiftT, "SetCurrentDate");
            textField.getActionMap().put("SetCurrentDate", aa);

        }

        String clearField = "ClearField";
        AbstractAction clearAction = new AbstractAction(clearField) {
            @Override
            public void actionPerformed(ActionEvent e) {
                destObj.setValue("", "");
            }
        };

        UIHelper.createLocalizedMenuItem(popupMenu, "ViewFactory.CLEAR", "", "", true, clearAction);

        textField.getInputMap().put(KeyStroke.getKeyStroke("F3"), clearField);
        textField.getActionMap().put(clearField, clearAction);

        textField.add(popupMenu);
        textField.setComponentPopupMenu(popupMenu);
    }
}

From source file:com.opendoorlogistics.studio.AppFrame.java

private void initWindowMenus(JMenu mnWindow) {
    mnWindow.add(new AbstractAction("Tile open windows") {

        @Override/*from w  ww . ja va  2 s  .c  o m*/
        public void actionPerformed(ActionEvent e) {
            tileWindows();
        }
    }).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, Event.CTRL_MASK));
    mnWindow.add(new AbstractAction("Cascade open windows") {

        @Override
        public void actionPerformed(ActionEvent e) {
            cascadeWindows();
        }
    }).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, Event.CTRL_MASK));

    mnWindow.add(new AbstractAction("Close all open windows") {

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

    mnWindow.add(new AbstractAction("Minimise all open windows") {

        @Override
        public void actionPerformed(ActionEvent e) {
            minimiseWindows();
        }
    }).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, Event.CTRL_MASK));

    mnWindow.add(new AbstractAction("Show all tables") {

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

    JMenu mnResizeTo = new JMenu("Resize application to...");
    for (final int[] size : new int[][] { new int[] { 1280, 720 }, new int[] { 1920, 1080 } }) {
        mnResizeTo.add(new AbstractAction("" + size[0] + " x " + size[1]) {

            @Override
            public void actionPerformed(ActionEvent e) {
                // set standard layout
                setSize(size[0], size[1]);
                splitterLeftPanelMain.setDividerLocation(0.175);
                splitterTablesScripts.setDividerLocation(0.3);
            }
        });
    }
    mnWindow.add(mnResizeTo);
}

From source file:com.imag.nespros.gui.plugin.GraphEditor.java

private static void initMenu() {
    JMenu menu = new JMenu("File");
    menu.add(new AbstractAction("Make Image") {
        public void actionPerformed(ActionEvent e) {
            JFileChooser chooser = new JFileChooser();
            int option = chooser.showSaveDialog(demo);
            if (option == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                demo.writeJPEGImage(file);
            }/* w ww .jav a 2s.c o  m*/
        }
    });
    menu.add(new AbstractAction("Print") {
        public void actionPerformed(ActionEvent e) {
            PrinterJob printJob = PrinterJob.getPrinterJob();
            printJob.setPrintable(demo);
            if (printJob.printDialog()) {
                try {
                    printJob.print();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
    });
    menu.add(new AbstractAction("Save topology") {
        public void actionPerformed(ActionEvent e) {
            JFileChooser chooser = new JFileChooser();
            int option = chooser.showSaveDialog(demo);
            if (option == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                try {
                    demo.save(file);
                    frame.setTitle(file.getName());
                } catch (IOException ex) {
                    Logger.getLogger(GraphEditor.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    });
    menu.add(new AbstractAction("Load topology") {
        public void actionPerformed(ActionEvent e) {
            JFileChooser chooser = new JFileChooser();
            int option = chooser.showOpenDialog(demo);
            if (option == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                try {
                    //EPGraph.getInstance().resetMapping();
                    simu.resetMapping();
                    demo.load(file);
                    frame.setTitle("Simulator - " + file.getName());
                } catch (FileNotFoundException ex) {
                    Logger.getLogger(GraphEditor.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    });
    JMenu menu2 = new JMenu("View");
    menu2.add(new AbstractAction("Layout") {
        @Override
        public void actionPerformed(ActionEvent e) {
            Layout l = new CircleLayout<Device, ComLink>(Topology.getInstance().getGraph());
            l.setInitializer(vv.getGraphLayout());
            l.setSize(vv.getSize());
            LayoutTransition<Device, ComLink> lt = new LayoutTransition<>(vv, vv.getGraphLayout(), l);
            Animator animator = new Animator(lt);
            animator.start();
            vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
            vv.repaint();
        }
    });
    menu2.add(new AbstractAction("Event Composition Networks") {
        @Override
        public void actionPerformed(ActionEvent e) {
            showEPGraph(EPGraph.getInstance().getGraph());
        }
    });
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(menu);
    menuBar.add(menu2);
    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(demo);
    frame.pack();
    frame.setVisible(true);
    buildEPGraphs();
    showEPGraph(EPGraph.getInstance().getGraph());
}

From source file:com.opendoorlogistics.studio.appframe.AppFrame.java

@SuppressWarnings("serial")
@Override/* w w  w. j  a  v a  2s . c  o  m*/
public void createNewDatastore() {
    if (!canCloseDatastore()) {
        return;
    }

    ArrayList<JButton> buttons = new ArrayList<>();

    for (NewDatastoreProvider ndp : newDatastoreProviders) {
        buttons.add(new JButton(new AbstractAction(ndp.name()) {

            @Override
            public void actionPerformed(ActionEvent e) {
                DatastoreLoader.useNewDatastoreProvider(AppFrame.this, ndp);
            }
        }));
    }

    launchButtonsListDialog("Create new spreadsheet", "Choose creation option:", null, buttons);
}

From source file:com.diversityarrays.kdxplore.trials.TrialOverviewPanel.java

public TrialOverviewPanel(String title, OfflineData offdata, TrialExplorerManager manager,
        FileListTransferHandler flth, MessagePrinter mp, final Closure<List<Trial>> onTrialSelected) {
    super(new BorderLayout());

    offlineData = offdata;/*www .  j  a v a2 s .  c o  m*/
    KdxploreDatabase kdxdb = offlineData.getKdxploreDatabase();
    if (kdxdb != null) {
        kdxdb.addEntityChangeListener(trialChangeListener);
        kdxdb.addEntityChangeListener(traitChangeListener);
    }

    this.messagePrinter = mp;

    TableTransferHandler tth = TableTransferHandler.initialiseForCopySelectAll(trialsTable, true);
    trialsTable.setTransferHandler(new ChainingTransferHandler(flth, tth));
    trialsTable.setAutoCreateRowSorter(true);

    trialsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                List<Trial> selectedTrials = getSelectedTrials();
                if (selectedTrials.size() == 1) {
                    trialTraitsTableModel.setSelectedTrial(selectedTrials.get(0));
                } else {
                    trialTraitsTableModel.setSelectedTrial(null);
                }
                onTrialSelected.execute(selectedTrials);
            }
        }
    });
    trialsTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2 && SwingUtilities.isLeftMouseButton(e)) {
                fireEditCommand(e);
            }
        }
    });

    GuiUtil.setVisibleRowCount(trialsTable, MAX_INITIAL_VISIBLE_TRIAL_ROWS);

    offlineData.addOfflineDataChangeListener(offlineDataChangeListener);

    trialTableModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            updateRefreshAction();
        }
    });
    trialTraitsTableModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            updateAddTraitAction();
            updateRemoveTraitAction();
            updateScoringOrderAction();
        }
    });
    trialTraitsTable.addMouseListener(new MouseAdapter() {

        List<Trait> selectedTraits;
        JPopupMenu popupMenu;
        Action showTraitsAction = new AbstractAction("Select in Trait Explorer") {
            @Override
            public void actionPerformed(ActionEvent e) {
                manager.showTraitsInTraitExplorer(selectedTraits);
            }
        };

        @Override
        public void mouseClicked(MouseEvent e) {

            if (SwingUtilities.isLeftMouseButton(e) && 2 == e.getClickCount()) {
                // Start editing the Trait
                e.consume();
                int vrow = trialTraitsTable.rowAtPoint(e.getPoint());
                if (vrow >= 0) {
                    int mrow = trialTraitsTable.convertRowIndexToModel(vrow);
                    if (mrow >= 0) {
                        Trait trait = trialTraitsTableModel.getTraitAt(mrow);
                        if (trait != null) {
                            traitExplorer.startEditing(trait);
                            ;
                        }
                    }
                }
            } else if (SwingUtilities.isRightMouseButton(e) && 1 == e.getClickCount()) {
                // Select the traits in the traitExplorer
                e.consume();
                List<Integer> modelRows = GuiUtil.getSelectedModelRows(trialTraitsTable);
                if (!modelRows.isEmpty()) {
                    selectedTraits = modelRows.stream().map(trialTraitsTableModel::getTraitAt)
                            .collect(Collectors.toList());

                    if (popupMenu == null) {
                        popupMenu = new JPopupMenu();
                        popupMenu.add(showTraitsAction);
                    }
                    Point pt = e.getPoint();
                    popupMenu.show(trialTraitsTable, pt.x, pt.y);
                }
            }
        }
    });
    trialTraitsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                updateRemoveTraitAction();
            }
        }
    });
    updateAddTraitAction();
    updateRemoveTraitAction();
    updateScoringOrderAction();
    updateRefreshAction();

    KDClientUtils.initAction(ImageId.REFRESH_24, refreshTrialTraitsAction, "Refresh");
    KDClientUtils.initAction(ImageId.MINUS_GOLD_24, removeTraitAction, "Remove selected Traits");
    KDClientUtils.initAction(ImageId.PLUS_BLUE_24, addTraitAction, "Add Traits to Trial");
    KDClientUtils.initAction(ImageId.TRAIT_ORDER_24, setScoringOrderAction, "Define Trait Scoring Order");

    Box buttons = Box.createHorizontalBox();

    buttons.add(new JButton(setScoringOrderAction));
    buttons.add(Box.createHorizontalGlue());
    buttons.add(new JButton(addTraitAction));
    buttons.add(new JButton(removeTraitAction));
    buttons.add(Box.createHorizontalStrut(10));
    buttons.add(refreshTrialTraitsButton);

    JPanel traitsPanel = new JPanel(new BorderLayout());
    traitsPanel.add(GuiUtil.createLabelSeparator("Uses Traits", buttons), BorderLayout.NORTH);
    traitsPanel.add(new PromptScrollPane(trialTraitsTable,
            "If the (single) selected Trial has Traits they will appear here"), BorderLayout.CENTER);

    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(trialsTable), traitsPanel);
    splitPane.setResizeWeight(0.5);

    add(splitPane, BorderLayout.CENTER);
}

From source file:org.nuclos.client.customcomp.resplan.ResPlanPanel.java

private void initJResPlan() {
    resPlan = new JResPlanComponent<Collectable, Date, Collectable, Collectable>(resPlanModel, timeModel);
    resPlan.getTimelineHeader().setCategoryModel(timeGranularityModel.getSelectedItem());
    resPlan.addMouseListener(new AbstractJPopupMenuListener() {
        @Override/*from www . jav a2 s  .c om*/
        protected JPopupMenu getJPopupMenu(MouseEvent evt) {
            JPopupMenu popupMenu = new JPopupMenu();
            Point pt = evt.getPoint();

            Area<Collectable, Date> blankSelection = resPlan.getSelectedBlankArea();
            if (blankSelection != null) {
                popupMenu.add(new AddAction(blankSelection.getResource(), blankSelection.getInterval()));
            } else {
                popupMenu.add(new AddAction(resPlan.getResourceAt(pt), resPlan.getTimeIntervalAt(pt)));
            }

            List<Collectable> selectedEntries = selectEntriesForEvent(pt);
            List<Collectable> selectedRelations = selectRelationsForEvent(pt);
            if (resPlan.isEditable() && (!selectedEntries.isEmpty() || !selectedRelations.isEmpty())) {
                JMenuItem menuItem = popupMenu.add(removeAction);
                boolean enabled = true;
                for (Collectable clct : selectedEntries) {
                    if (!resPlanModel.isRemoveEntryAllowed(clct)) {
                        enabled = false;
                        break;
                    }
                }
                for (Collectable clct : selectedRelations) {
                    if (!resPlanModel.isRemoveRelationAllowed(clct)) {
                        enabled = false;
                        break;
                    }
                }
                // Note: just change the state of the menu item (and leave the action as is)
                menuItem.setEnabled(enabled);
            }
            if (!selectedEntries.isEmpty() || !selectedRelations.isEmpty()) {
                popupMenu.add(detailsAction);
            }

            if (selectedEntries.size() == 1 && resPlanModel.getRelationEntity() != null
                    && resPlanModel.isCreateRelationAllowed()) {
                popupMenu.addSeparator();
                if (resPlan.getRelateBegin() != null) {
                    Collectable to = selectedEntries.get(0);
                    if (to != resPlan.getRelateBegin()) {
                        popupMenu.add(relateFinishAction);
                    }
                }
                popupMenu.add(relateBeginAction);
            }

            return popupMenu;
        }

        private List<Collectable> selectEntriesForEvent(Point pt) {
            List<Collectable> selection = resPlan.getSelectedEntries();
            Collectable entryAt = resPlan.getEntryAt(pt);
            if (entryAt != null && (selection.isEmpty() || !selection.contains(entryAt))) {
                selection = Collections.singletonList(entryAt);
                resPlan.setSelectedEntries(selection);
            }
            return selection;
        }

        private List<Collectable> selectRelationsForEvent(Point pt) {
            List<Collectable> selection = resPlan.getSelectedRelations();
            Collectable relAt = resPlan.getRelationAt(pt);
            if (relAt != null && (selection.isEmpty() || !selection.contains(relAt))) {
                selection = Collections.singletonList(relAt);
                resPlan.setSelectedRelations(selection);
            }
            return selection;
        }

        @Override
        public void mouseClicked(MouseEvent evt) {
            if (evt.getClickCount() == 2) {
                Collectable clct = resPlan.getEntryAt(evt.getPoint());
                if (clct == null) {
                    clct = resPlan.getRelationAt(evt.getPoint());
                    if (clct != null) {
                        runDetailsCollectable(resPlanModel.getRelationEntity().getEntityName(), clct);
                    }
                } else {
                    runDetailsCollectable(resPlanModel.getEntryEntity().getEntityName(), clct);
                }
                evt.consume();
            }
        }
    });
    resPlan.getResourceHeader().addMouseListener(new AbstractJPopupMenuListener() {
        @Override
        public void mouseClicked(MouseEvent evt) {
            if (evt.getClickCount() == 2) {
                Collectable clct = resPlan.getResourceHeader().getValueAt(evt.getPoint());
                runDetailsCollectable(resPlanModel.getResourceEntity().getEntityName(), clct);
                evt.consume();
            }
        }

        @Override
        protected JPopupMenu getJPopupMenu(MouseEvent evt) {
            final Collectable clct = resPlan.getResourceHeader().getValueAt(evt.getPoint());
            if (clct != null) {
                JPopupMenu popupMenu = new JPopupMenu();
                popupMenu.add(new AbstractAction(
                        SpringLocaleDelegate.getInstance().getText("nuclos.resplan.action.showDetails")) {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        runDetailsCollectable(resPlanModel.getResourceEntity().getEntityName(), clct);
                    }
                });
                return popupMenu;
            }
            return null;
        }
    });
    Date start = DateUtils.addDays(DateUtils.getPureDate(new Date()), -5);
    Date end = DateUtils.addDays(start, 30);
    resPlan.setTimeHorizon(new Interval<Date>(start, end));
}

From source file:org.apache.jmeter.gui.MainFrame.java

private void addQuickComponentHotkeys(JTree treevar) {
    Action quickComponent = new AbstractAction("Quick Component") {
        private static final long serialVersionUID = 1L;

        @Override//from ww w .  j ava  2s  .c  om
        public void actionPerformed(ActionEvent actionEvent) {
            String propname = "gui.quick_" + actionEvent.getActionCommand();
            String comp = JMeterUtils.getProperty(propname);
            log.debug("Event " + propname + ": " + comp);

            if (comp == null) {
                log.warn("No component set through property: " + propname);
                return;
            }

            GuiPackage guiPackage = GuiPackage.getInstance();
            try {
                guiPackage.updateCurrentNode();
                TestElement testElement = guiPackage.createTestElement(SaveService.aliasToClass(comp));
                JMeterTreeNode parentNode = guiPackage.getCurrentNode();
                while (!MenuFactory.canAddTo(parentNode, testElement)) {
                    parentNode = (JMeterTreeNode) parentNode.getParent();
                }
                if (parentNode.getParent() == null) {
                    log.debug("Cannot add element on very top level");
                } else {
                    JMeterTreeNode node = guiPackage.getTreeModel().addComponent(testElement, parentNode);
                    guiPackage.getMainFrame().getTree().setSelectionPath(new TreePath(node.getPath()));
                }
            } catch (Exception err) {
                log.warn("Failed to perform quick component add: " + comp, err); // $NON-NLS-1$
            }
        }
    };

    InputMap inputMap = treevar.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    KeyStroke[] keyStrokes = new KeyStroke[] { KeyStrokes.CTRL_0, KeyStrokes.CTRL_1, KeyStrokes.CTRL_2,
            KeyStrokes.CTRL_3, KeyStrokes.CTRL_4, KeyStrokes.CTRL_5, KeyStrokes.CTRL_6, KeyStrokes.CTRL_7,
            KeyStrokes.CTRL_8, KeyStrokes.CTRL_9, };
    for (int n = 0; n < keyStrokes.length; n++) {
        treevar.getActionMap().put(ActionNames.QUICK_COMPONENT + String.valueOf(n), quickComponent);
        inputMap.put(keyStrokes[n], ActionNames.QUICK_COMPONENT + String.valueOf(n));
    }
}

From source file:net.panthema.BispanningGame.GamePanel.java

void makeActions() {
    actionRandomGraph[0] = new AbstractAction("Empty Graph") {
        private static final long serialVersionUID = 571719411573657773L;

        public void actionPerformed(ActionEvent e) {
            makeNewRandomGraph(0);//from  www  .  j a va2s  . c  o  m
        }
    };
    actionRandomGraph[4] = new AbstractAction("4 Vertices") {
        private static final long serialVersionUID = 571719411573657774L;

        public void actionPerformed(ActionEvent e) {
            makeNewRandomGraph(4);
        }
    };
    actionRandomGraph[5] = new AbstractAction("5 Vertices") {
        private static final long serialVersionUID = 571719411573657775L;

        public void actionPerformed(ActionEvent e) {
            makeNewRandomGraph(5);
        }
    };
    actionRandomGraph[6] = new AbstractAction("6 Vertices") {
        private static final long serialVersionUID = 571719411573657776L;

        public void actionPerformed(ActionEvent e) {
            makeNewRandomGraph(6);
        }
    };
    actionRandomGraph[7] = new AbstractAction("7 Vertices") {
        private static final long serialVersionUID = 571719411573657777L;

        public void actionPerformed(ActionEvent e) {
            makeNewRandomGraph(7);
        }
    };
    actionRandomGraph[8] = new AbstractAction("8 Vertices") {
        private static final long serialVersionUID = 571719411573657778L;

        public void actionPerformed(ActionEvent e) {
            makeNewRandomGraph(8);
        }
    };
    actionRandomGraph[9] = new AbstractAction("9 Vertices") {
        private static final long serialVersionUID = 571719411573657779L;

        public void actionPerformed(ActionEvent e) {
            makeNewRandomGraph(9);
        }
    };
    actionRandomGraph[10] = new AbstractAction("10 Vertices") {
        private static final long serialVersionUID = 571719411573657780L;

        public void actionPerformed(ActionEvent e) {
            makeNewRandomGraph(10);
        }
    };
    actionRandomGraph[11] = new AbstractAction("11 Vertices") {
        private static final long serialVersionUID = 571719411573657781L;

        public void actionPerformed(ActionEvent e) {
            makeNewRandomGraph(11);
        }
    };
    actionRandomGraph[12] = new AbstractAction("12 Vertices") {
        private static final long serialVersionUID = 571719411573657782L;

        public void actionPerformed(ActionEvent e) {
            makeNewRandomGraph(12);
        }
    };
    actionRandomGraph[13] = new AbstractAction("13 Vertices") {
        private static final long serialVersionUID = 571719411573657783L;

        public void actionPerformed(ActionEvent e) {
            makeNewRandomGraph(13);
        }
    };
    actionRandomGraph[14] = new AbstractAction("14 Vertices") {
        private static final long serialVersionUID = 571719411573657784L;

        public void actionPerformed(ActionEvent e) {
            makeNewRandomGraph(14);
        }
    };
    actionRandomGraph[15] = new AbstractAction("15 Vertices") {
        private static final long serialVersionUID = 571719411573657785L;

        public void actionPerformed(ActionEvent e) {
            makeNewRandomGraph(15);
        }
    };
    actionRandomGraph[16] = new AbstractAction("16 Vertices") {
        private static final long serialVersionUID = 571719411573657786L;

        public void actionPerformed(ActionEvent e) {
            makeNewRandomGraph(16);
        }
    };
    actionRandomGraph[17] = new AbstractAction("17 Vertices") {
        private static final long serialVersionUID = 571719411573657787L;

        public void actionPerformed(ActionEvent e) {
            makeNewRandomGraph(17);
        }
    };
    actionRandomGraph[18] = new AbstractAction("18 Vertices") {
        private static final long serialVersionUID = 571719411573657788L;

        public void actionPerformed(ActionEvent e) {
            makeNewRandomGraph(18);
        }
    };
    actionRandomGraph[19] = new AbstractAction("19 Vertices") {
        private static final long serialVersionUID = 571719411573657789L;

        public void actionPerformed(ActionEvent e) {
            makeNewRandomGraph(19);
        }
    };
    actionRandomGraph[20] = new AbstractAction("20 Vertices") {
        private static final long serialVersionUID = 571719411573657790L;

        public void actionPerformed(ActionEvent e) {
            makeNewRandomGraph(20);
        }
    };

    // Special Named Graphs

    actionNamedGraph.add(new AbstractAction("K4 (complete, 4 vertices)") {
        private static final long serialVersionUID = 571719411573657791L;

        public void actionPerformed(ActionEvent e) {
            loadGraphString(
                    "V4:i0x0y0/i1x1y0/i2x1y1/i3x0y1/;E6:i0t0h1c1/i1t0h2c1/i2t0h3c2/i3t1h2c2/i4t1h3c2/i5t2h3c1/;");
        }
    });

    actionNamedGraph.add(new AbstractAction("W5 (wheel, 5 vertices)") {
        private static final long serialVersionUID = 571719411573657792L;

        public void actionPerformed(ActionEvent e) {
            loadGraphString(
                    "V5:i0x10y10/i1x10y0/i2x0y10/i3x10y20/i4x20y10/;E8:i0t0h1c1/i1t1h2c1/i2t2h0c2/i3t2h3c1/i4t3h0c2/i5t3h4c1/i6t4h0c2/i7t4h1c2/;");
        }
    });

    actionNamedGraph.add(new AbstractAction("K4 + K4 (2-clique sum, 6 vertices)") {
        private static final long serialVersionUID = 571719411573657793L;

        public void actionPerformed(ActionEvent e) {
            loadGraphString(
                    "V6:i0x0y0/i1x1y0/i2x1y1/i3x0y1/i4x2y0/i5x2y1/;E10:i0t0h1c1/i1t0h2c2/i2t0h3c1/i4t1h3c2/i5t2h3c2/i6t1h4c2/i7t1h5c1/i9t4h5c2/i10t4h2c1/i11t2h5c1/;");
        }
    });

    actionNamedGraph.add(new AbstractAction("B 6,12 difficult (6 vertices)") {
        private static final long serialVersionUID = 571719411573457792L;

        public void actionPerformed(ActionEvent e) {
            loadGraphString(
                    "V6:i0x0y12/i1x20y15/i2x40y12/i3x10y30/i4x20y0/i5x30y30/;E10:i0t0h3c2/i1t1h3c1/i2t2h3c1/i3t0h4c1/i4t1h4c2/i5t2h4c2/i6t0h5c1/i7t1h5c2/i8t2h5c1/i9t3h5c2/;");
        }
    });

    actionNamedGraph.add(new AbstractAction("W6 (wheel, 6 vertices)") {
        private static final long serialVersionUID = 571719411573657794L;

        public void actionPerformed(ActionEvent e) {
            loadGraphString(
                    "V6:i0x0y0/i1x0y-1000/i2x-951y-309/i3x-588y809/i4x588y809/i5x951y-309/;E10:i0t0h1c1/i1t1h2c1/i2t0h2c2/i3t2h3c1/i4t0h3c2/i5t3h4c1/i6t0h4c2/i7t4h5c1/i8t0h5c2/i9t5h1c2/;");
        }
    });

    actionNamedGraph.add(new AbstractAction("B7,1 triangle free (7 vertices)") {
        private static final long serialVersionUID = 571719411573657796L;

        public void actionPerformed(ActionEvent e) {
            loadGraphString(
                    "V7:i0x2y0/i1x2y2/i2x2y4/i3x0y1/i4x0y3/i5x4y1/i6x4y3/;E12:i0t3h0c2/i1t3h1c1/i2t3h2c1/i3t4h0c2/i4t4h1c2/i5t4h2c1/i6t5h0c1/i7t5h1c2/i8t5h2c2/i9t6h0c1/i10t6h1c1/i11t6h2c2/;");
        }
    });

    actionNamedGraph.add(new AbstractAction("B8,1 triangle free (8 vertices)") {
        private static final long serialVersionUID = 571719411573657798L;

        public void actionPerformed(ActionEvent e) {
            loadGraphString(
                    "V8:i0x10y20/i1x20y10/i2x40y35/i3x0y35/i4x40y15/i5x0y15/i6x30y30/i7x20y40/;E14:i0t0h4c1/i1t1h4c2/i2t2h4c1/i3t0h5c1/i4t1h5c2/i5t3h5c2/i6t0h6c2/i7t1h6c1/i8t2h6c2/i9t3h6c1/i10t0h7c2/i11t1h7c1/i12t2h7c1/i13t3h7c2/;");
        }
    });

    actionNamedGraph.add(new AbstractAction("B9,1 difficult (9 vertices)") {
        private static final long serialVersionUID = 571719411573657796L;

        public void actionPerformed(ActionEvent e) {
            loadGraphString(
                    "V9:i0x1y0/i1x3y2/i2x1y2/i3x1y1/i4x3y1/i5x0y1/i6x0y2/i7x2y2/i8x2y1/;E16:i0t0h4c1/i1t1h4c1/i2t0h5c2/i3t2h5c2/i4t3h5c1/i5t0h6c2/i6t2h6c1/i7t3h6c2/i8t1h7c1/i9t2h7c1/i10t3h7c2/i11t4h7c2/i12t0h8c1/i13t1h8c2/i14t2h8c2/i15t3h8c1/;");
        }
    });

    actionNamedGraph.add(new AbstractAction("2x2 K4 grid (9 vertices)") {
        private static final long serialVersionUID = 571719411573657796L;

        public void actionPerformed(ActionEvent e) {
            loadGraphString(
                    "V9:i0x0y0/i1x1y0/i2x2y0/i3x0y1/i4x1y1/i5x2y1/i6x0y2/i7x1y2/i8x2y2/;E16:i0t0h1c1/i1t0h4c2/i2t0h3c2/i3t1h2c2/i4t1h3c2/i5t1h5c1/i6t2h4c1/i7t2h5c1/i8t3h6c1/i9t3h7c1/i10t4h6c1/i11t4h8c2/i12t5h7c2/i13t5h8c2/i14t6h7c2/i15t7h8c1/;");
        }
    });

    actionNamedGraph.add(new AbstractAction("B10,1 difficult (10 vertices)") {
        private static final long serialVersionUID = 571419411573657796L;

        public void actionPerformed(ActionEvent e) {
            loadGraphString(
                    "V10:i0x20y6/i1x0y-25/i2x0y25/i3x-20y6/i4x30y-12/i5x-30y13/i6x30y13/i7x-30y-12/i8x-10y-10/i9x10y-10/;E18:i0t0h4c1/i1t1h4c2/i2t0h5c2/i3t2h5c1/i4t2h6c2/i5t3h6c1/i6t4h6c2/i7t1h7c1/i8t3h7c2/i9t5h7c1/i10t0h8c1/i11t1h8c2/i12t2h8c1/i13t3h8c2/i14t0h9c2/i15t1h9c1/i16t2h9c2/i17t3h9c1/;");
        }
    });

    actionNamedGraph.add(new AbstractAction("B10,2 difficult (10 vertices)") {
        private static final long serialVersionUID = 571419411573657796L;

        public void actionPerformed(ActionEvent e) {
            loadGraphString(
                    "V10:i0x10y10/i1x10y20/i2x30y20/i3x30y10/i4x0y25/i5x40y5/i6x40y25/i7x0y5/i8x20y10/i9x20y20/;E18:i0t0h4c2/i1t1h4c1/i2t2h5c2/i3t3h5c1/i4t2h6c1/i5t3h6c2/i6t4h6c1/i7t0h7c1/i8t1h7c2/i9t5h7c2/i10t0h8c1/i11t1h8c1/i12t2h8c2/i13t3h8c2/i14t0h9c2/i15t1h9c2/i16t2h9c1/i17t3h9c1/;");
        }
    });

    actionNamedGraph.add(new AbstractAction("B11,1 difficult (11 vertices)") {
        private static final long serialVersionUID = 571419411573657796L;

        public void actionPerformed(ActionEvent e) {
            loadGraphString(
                    "V11:i0x30y24/i1x0y24/i2x15y0/i3x25y17/i4x5y17/i5x15y20/i6x30y8/i7x0y8/i8x20y8/i9x15y30/i10x10y8/;E20:i0t0h5c1/i1t1h5c2/i2t0h6c2/i3t2h6c2/i4t3h6c1/i5t1h7c1/i6t2h7c1/i7t4h7c2/i8t2h8c2/i9t3h8c1/i10t4h8c1/i11t5h8c2/i12t0h9c2/i13t1h9c1/i14t3h9c2/i15t4h9c1/i16t2h10c1/i17t3h10c2/i18t4h10c2/i19t5h10c1/;");
        }
    });

    actionNamedGraph.add(new AbstractAction("B11,2 difficult (11 vertices)") {
        private static final long serialVersionUID = 571419411573657797L;

        public void actionPerformed(ActionEvent e) {
            loadGraphString(
                    "V11:i0x3y2/i1x1y2/i2x3y1/i3x1y1/i4x4y1/i5x0y1/i6x4y2/i7x0y2/i8x2y2/i9x2y0/i10x2y1/;E20:i0t0h4c1/i1t1h5c2/i2t0h6c2/i3t2h6c1/i4t4h6c2/i5t1h7c1/i6t3h7c2/i7t5h7c1/i8t0h8c2/i9t1h8c1/i10t2h8c1/i11t3h8c2/i12t2h9c2/i13t3h9c1/i14t4h9c2/i15t5h9c1/i16t0h10c1/i17t1h10c2/i18t2h10c2/i19t3h10c1/;");
        }
    });

    actionNamedGraph.add(new AbstractAction("B12,1 difficult (12 vertices)") {
        private static final long serialVersionUID = 571419411573657796L;

        public void actionPerformed(ActionEvent e) {
            loadGraphString(
                    "V12:i0x30y30/i1x10y30/i2x30y0/i3x10y0/i4x25y10/i5x20y20/i6x40y20/i7x0y20/i8x30y20/i9x10y20/i10x15y10/i11x20y0/;E22:i0t0h5c1/i1t1h5c2/i2t0h6c2/i3t2h6c1/i4t1h7c1/i5t3h7c2/i6t1h8c1/i7t2h8c2/i8t4h8c1/i9t6h8c2/i10t0h9c2/i11t3h9c1/i12t4h9c2/i13t7h9c1/i14t2h10c1/i15t3h10c1/i16t4h10c2/i17t5h10c2/i18t2h11c2/i19t3h11c2/i20t4h11c1/i21t5h11c1/;");
        }
    });

    actionNamedGraph.add(new AbstractAction("B12,2 difficult (12 vertices)") {
        private static final long serialVersionUID = 571419411573657796L;

        public void actionPerformed(ActionEvent e) {
            loadGraphString(
                    "V12:i0x10y0/i1x30y0/i2x30y20/i3x15y30/i4x12y40/i5x40y30/i6x0y10/i7x40y10/i8x25y30/i9x10y20/i10x0y30/i11x28y40/;E22:i0t0h5c1/i1t1h5c2/i2t0h6c1/i3t2h6c1/i4t1h7c2/i5t2h7c2/i6t2h8c1/i7t3h8c1/i8t4h8c2/i9t5h8c2/i10t1h9c1/i11t3h9c1/i12t4h9c2/i13t6h9c2/i14t0h10c2/i15t3h10c2/i16t4h10c1/i17t7h10c1/i18t2h11c2/i19t3h11c2/i20t4h11c1/i21t5h11c1/;");
        }
    });

    actionNamedGraph.add(new AbstractAction("B12,3 difficult (12 vertices)") {
        private static final long serialVersionUID = 571419411573657796L;

        public void actionPerformed(ActionEvent e) {
            loadGraphString(
                    "V12:i0x10y5/i1x10y25/i2x30y10/i3x30y20/i4x10y10/i5x10y20/i6x30y5/i7x30y25/i8x20y10/i9x3y15/i10x37y15/i11x20y20/;E22:i0t0h4c2/i1t1h5c1/i2t0h6c1/i3t2h6c2/i4t1h7c2/i5t3h7c1/i6t2h8c1/i7t3h8c2/i8t4h8c2/i9t5h8c1/i10t0h9c1/i11t1h9c2/i12t4h9c1/i13t5h9c2/i14t2h10c1/i15t3h10c2/i16t6h10c1/i17t7h10c2/i18t2h11c2/i19t3h11c1/i20t4h11c1/i21t5h11c2/;");
        }
    });

    actionNamedGraph.add(new AbstractAction("B12,4 difficult (12 vertices)") {
        private static final long serialVersionUID = 571419411573657796L;

        public void actionPerformed(ActionEvent e) {
            loadGraphString(
                    "V12:i0x10y10/i1x25y20/i2x40y10/i3x40y0/i4x10y0/i5x10y20/i6x50y10/i7x0y10/i8x40y20/i9x20y10/i10x30y10/i11x25y0/;E22:i0t0h5c1/i1t1h5c2/i2t2h6c1/i3t3h6c2/i4t0h7c2/i5t4h7c1/i6t5h7c2/i7t1h8c1/i8t2h8c2/i9t6h8c1/i10t0h9c1/i11t1h9c2/i12t3h9c1/i13t4h9c2/i14t1h10c1/i15t2h10c2/i16t3h10c1/i17t4h10c2/i18t0h11c2/i19t2h11c1/i20t3h11c2/i21t4h11c1/;");
        }
    });

    actionNamedGraph.add(new AbstractAction("3x3 K4 grid (16 vertices)") {
        private static final long serialVersionUID = 571719411573657796L;

        public void actionPerformed(ActionEvent e) {
            loadGraphString(
                    "V16:i0x0y0/i1x1y0/i2x2y0/i3x3y0/i4x0y1/i5x1y1/i6x2y1/i7x3y1/i8x0y2/i9x1y2/i10x2y2/i11x3y2/i12x0y3/i13x1y3/i14x2y3/i15x3y3/;E30:i0t0h1c1/i1t0h5c2/i2t0h4c2/i3t1h2c1/i4t1h4c2/i5t1h6c2/i6t2h3c2/i7t2h5c2/i8t2h7c1/i9t3h6c1/i10t3h7c1/i11t4h8c1/i12t4h9c1/i13t5h8c1/i14t5h10c1/i15t6h9c1/i16t6h11c2/i17t7h10c2/i18t7h11c2/i19t8h12c2/i20t8h13c2/i21t9h12c2/i22t9h14c2/i23t10h13c2/i24t10h15c1/i25t11h14c1/i26t11h15c1/i27t12h13c1/i28t13h14c1/i29t14h15c2/;");
        }
    });

    actionNamedGraph.add(new AbstractAction("B18,1 square-free (18 vertices)") {
        private static final long serialVersionUID = 571719411573657796L;

        public void actionPerformed(ActionEvent e) {
            loadGraphString(
                    "V18:i0x0y0/i1x100y0/i2x200y0/i3x300y0/i4x300y100/i5x300y200/i6x200y200/i7x100y200/i8x0y200/i9x0y100/i10x40y40/i11x150y25/i12x260y40/i13x260y160/i14x150y175/i15x40y160/i16x175y70/i17x125y130/;E34:i0t0h1c1/i1t1h2c2/i2t2h3c2/i3t3h4c1/i4t4h5c2/i5t5h6c1/i6t6h7c2/i7t7h8c1/i8t8h9c1/i9t9h0c2/i10t0h10c1/i11t3h12c1/i12t5h13c1/i13t8h15c2/i14t9h16c1/i15t4h17c2/i16t4h11c2/i17t9h14c2/i18t1h15c1/i19t1h17c1/i20t2h16c1/i21t2h13c2/i22t6h12c1/i23t6h16c2/i24t7h17c1/i25t7h10c2/i26t10h11c2/i27t10h13c2/i28t11h16c1/i29t11h15c2/i30t12h15c2/i31t12h14c2/i32t13h14c1/i33t14h17c1/;");
        }
    });
}

From source file:com.github.lindenb.jvarkit.tools.bamviewgui.BamFileRef.java

BamFrame(List<BamFileRef> BamFileRefs) {
    super((JFrame) null, "Bam View (" + BamFileRefs.size() + " files)", ModalityType.APPLICATION_MODAL);
    this.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    this.BamFileRefs = BamFileRefs;

    addWindowListener(new WindowAdapter() {

        @Override//from ww  w  .ja  va  2  s  .c om
        public void windowOpened(WindowEvent e) {
            removeWindowListener(this);
            Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
            d.width -= 150;
            d.height -= 150;
            for (BamFileRef vfr : BamFrame.this.BamFileRefs) {
                LOG.info("Reading " + vfr.bamFile);
                int w = (int) (d.width * 0.8);
                int h = (int) (d.height * 0.8);
                BamInternalFrame iFrame = new BamInternalFrame(vfr);
                iFrame.setBounds(Math.max((int) ((d.width - w) * Math.random()), 0),
                        Math.max((int) ((d.height - h) * Math.random()), 0), w, h);
                desktopPane.add(iFrame);
                BamInternalFrames.add(iFrame);
                iFrame.setVisible(true);
                iFrame.jTable.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent e) {
                        if (e.getClickCount() == 2) {
                            JTable t = (JTable) e.getSource();
                            int row = t.getSelectedRow();
                            if (row == -1)
                                return;
                            BamTableModel tm = (BamTableModel) t.getModel();
                            showIgv(tm.getValueAt(row, 0), tm.getValueAt(row, 1));
                        }
                    }
                });
            }
            reloadFrameContent();
        }
    });

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            doMenuClose();
        }
    });
    JMenuBar bar = new JMenuBar();
    setJMenuBar(bar);

    JMenu menu = new JMenu("File");
    bar.add(menu);
    menu.add(new AbstractAction("Quit") {
        @Override
        public void actionPerformed(ActionEvent e) {
            doMenuClose();
        }
    });

    menu = new JMenu("Flags");
    bar.add(menu);
    for (SamFlag flag : SamFlag.values()) {
        JCheckBox cbox = new JCheckBox("Require " + flag);
        requiredFlags.add(cbox);
        menu.add(cbox);
    }
    menu.add(new JSeparator());
    for (SamFlag flag : SamFlag.values()) {
        JCheckBox cbox = new JCheckBox("Filter out " + flag);
        filteringFlags.add(cbox);
        menu.add(cbox);
    }

    JPanel contentPane = new JPanel(new BorderLayout(5, 5));
    setContentPane(contentPane);
    this.desktopPane = new JDesktopPane();
    contentPane.add(this.desktopPane, BorderLayout.CENTER);

    JPanel top = new JPanel(new FlowLayout(FlowLayout.LEADING));
    contentPane.add(top, BorderLayout.NORTH);

    JLabel lbl = new JLabel("Max Rows:", JLabel.LEADING);
    JSpinner spinner = new JSpinner(this.numFetchModel = new SpinnerNumberModel(100, 1, 10000, 10));
    lbl.setLabelFor(spinner);
    top.add(lbl);
    top.add(spinner);

    lbl = new JLabel("Timeout (secs):", JLabel.LEADING);
    spinner = new JSpinner(this.numSecondsModel = new SpinnerNumberModel(2, 1, 10000, 1));
    lbl.setLabelFor(spinner);
    top.add(lbl);
    top.add(spinner);

    //lbl=new JLabel("JEXL:",JLabel.LEADING);
    /*jexlField=new JTextField(20);
    lbl.setLabelFor(jexlField);
            
    top.add(lbl);
    top.add(jexlField);*/

    lbl = new JLabel("Region:", JLabel.LEADING);
    selectRgnField = new JTextField(20);
    lbl.setLabelFor(selectRgnField);
    AbstractAction action = new AbstractAction("Select") {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent a) {
            if (
            /* (jexlField.getText().trim().isEmpty() || parseJex(jexlField.getText().trim())!=null) && */
            (selectRgnField.getText().trim().isEmpty() || parseOne(selectRgnField.getText()) != null)) {
                reloadFrameContent();
            } else {
                LOG.info("Bad input " + selectRgnField.getText());
            }
        }
    };
    selectRgnField.addActionListener(action);
    //jexlField.addActionListener(action);

    top.add(lbl);
    top.add(selectRgnField);
    top.add(new JButton(action));

}