Example usage for javax.swing JPopupMenu JPopupMenu

List of usage examples for javax.swing JPopupMenu JPopupMenu

Introduction

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

Prototype

public JPopupMenu() 

Source Link

Document

Constructs a JPopupMenu without an "invoker".

Usage

From source file:com.peterbochs.PeterBochsDebugger.java

private JPopupMenu getJHexTablePopupMenu() {
    if (jHexTablePopupMenu == null) {
        jHexTablePopupMenu = new JPopupMenu();
        jHexTablePopupMenu.add(getJMenu7());
        jHexTablePopupMenu.add(getJMenu8());
        jHexTablePopupMenu.add(getJMenuItem4());
        jHexTablePopupMenu.add(getJMenuItem5());
        jHexTablePopupMenu.add(getJMenuItem6());
        jHexTablePopupMenu.add(getJMenuItem7());
        jHexTablePopupMenu.add(getJDisassemble32MenuItem());
    }//www.  j av a2s . com
    return jHexTablePopupMenu;
}

From source file:com.peterbochs.PeterBochsDebugger.java

private JPopupMenu getJInstructionPanelPopupMenu() {
    if (jInstructionPanelPopupMenu == null) {
        jInstructionPanelPopupMenu = new JPopupMenu();
        jInstructionPanelPopupMenu.add(getJSetPhysicalBreakpointMenuItem());
        jInstructionPanelPopupMenu.add(getJSetLinearBreakpointMenuItem());
        jInstructionPanelPopupMenu.add(getJSeparator3());
        jInstructionPanelPopupMenu.add(getJDisasmHereMenuItem());
        jInstructionPanelPopupMenu.add(getDisasmFromEIPMinus100MenuItem());
        jInstructionPanelPopupMenu.add(getClearInstructionTableMenuItem());
    }/*from   w w w  . ja  v a 2s. co  m*/
    return jInstructionPanelPopupMenu;
}

From source file:com.peterbochs.PeterBochsDebugger.java

private JPopupMenu getJBreakpointPopupMenu() {
    if (jBreakpointPopupMenu == null) {
        jBreakpointPopupMenu = new JPopupMenu();
        jBreakpointPopupMenu.add(getJMenuItem6x());
        jBreakpointPopupMenu.add(getJMenuItem7x());
    }//from   w  ww  .j a v  a  2s .  co m
    return jBreakpointPopupMenu;
}

From source file:com.peterbochs.PeterBochsDebugger.java

private JPopupMenu getJSearchMemoryTablePopupMenu() {
    if (jSearchMemoryTablePopupMenu == null) {
        jSearchMemoryTablePopupMenu = new JPopupMenu();
        jSearchMemoryTablePopupMenu.add(getJMenuItem8());
        jSearchMemoryTablePopupMenu.add(getJMenuItem9());
    }//from w w  w .j  av  a  2  s .co  m
    return jSearchMemoryTablePopupMenu;
}

From source file:com.peterbochs.PeterBochsDebugger.java

private JPopupMenu getJELFTablePopupMenu() {
    if (jELFTablePopupMenu == null) {
        jELFTablePopupMenu = new JPopupMenu();
        jELFTablePopupMenu.add(getJMenuItem1x());
        jELFTablePopupMenu.add(getJMenuItem2x());
    }/*from w ww  .  j  a va  2s.co  m*/
    return jELFTablePopupMenu;
}

From source file:network.view.relacoesEntidadesUI.GraphViewEntity.java

@SuppressWarnings("deprecation")
public GraphViewEntity(Grafo g) {

    try {/*from  ww  w .ja  v  a  2  s.c  o m*/
        //this.grafo = g;
        graph = getGraph(g);
    } catch (Exception e) {
        graph = TestGraphs.getOneComponentGraph();
    }

    vv = paintGraph(graph, g);

    frame = new JFrame("Relao entre Entidades");
    Container content = frame.getContentPane();
    panel = new JPanel(new BorderLayout());
    panel.add(vv);

    content.add(panel);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.setIconImage(SwingResourceManager.getImage(GraphViewEntity.class,
            "/br/atech/smartsearch/view/images/logo-small.JPG"));
    dialog = new JDialog(frame);

    content = dialog.getContentPane();

    // create the BirdsEyeView for zoom/pan
    final edu.uci.ics.jung.visualization.BirdsEyeVisualizationViewer bird = new edu.uci.ics.jung.visualization.BirdsEyeVisualizationViewer(
            vv, 0.25f, 0.25f);

    JButton reset = new JButton("Sem Zoom");
    // 'reset' unzooms the graph via the Lens
    reset.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            bird.resetLens();
        }
    });
    final ScalingControl scaler = new ViewScalingControl();
    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 0.9f, vv.getCenter());
        }
    });
    JButton help = new JButton("Ajuda");
    help.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String zoomHelp = "<html><center>Arraste o retngulo azul para deslocar a imagem<p>"
                    + "Arraste um lado do retngulo para ajustar o zoom</center></html>";
            JOptionPane.showMessageDialog(dialog, zoomHelp);
        }
    });
    JPanel controls = new JPanel(new GridLayout(2, 2));
    controls.add(plus);
    controls.add(minus);
    controls.add(reset);
    controls.add(help);
    content.add(bird);
    content.add(controls, BorderLayout.SOUTH);

    JButton zoomer = new JButton("Mostrar tela de zoom");
    zoomer.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dialog.pack();
            int w = dialog.getWidth() + 5;
            int h = dialog.getHeight() + 5; // 35;
            dialog.setLocation((int) (frame.getLocationOnScreen().getX() + frame.getWidth() - w),
                    (int) frame.getLocationOnScreen().getY() + frame.getHeight() - h);
            //dialog.show();
            dialog.setVisible(true);
            //bird.initLens();
        }
    });

    // [mcrb] Popup menu (Agrupar/Remover/Remover Selecao)
    popup = new JPopupMenu();

    menuItem = new JMenuItem("Agrupar Nodos");
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //TODO
        }
    });
    popup.add(menuItem);

    menuItem = new JMenuItem("Remover Nodo");
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myVertexDisplayPredicate.filter(true);
            clicksFiltro.add(selecionado);
            pr.setVertexPaintFunction(new MyVertexPaintFunction());
            vv.repaint();
        }
    });
    popup.add(menuItem);

    menuItem = new JMenuItem("Remover Seleo");
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            clicks = new ArrayList<Vertex>();
            pr.setVertexPaintFunction(new MyVertexPaintFunction());
            // para evitar que o 'ultimo selecionado permaneca em destaque:
            selecionado = null;
            vv.repaint();
        }
    });
    popup.add(menuItem);

    labelFiltroArestas = new JLabel("Apresentar arestas com tamanho maior que ");
    textFieldFiltroArestas = new JTextField(2);

    buttonFiltroArestas = new JButton("Filtrar");
    buttonEliminarFiltroArestas = new JButton("Remover Filtros");
    buttonEliminarFiltroArestas.setEnabled(false);

    buttonFiltroArestas.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Object objValue = textFieldFiltroArestas.getText();
            try {
                new Integer((String) objValue).intValue();
            } catch (NumberFormatException ex) {
                objValue = "0";
                textFieldFiltroArestas.setText("");
            }
            espessurasSelecionadas.add(objValue);
            myEdgeDisplayPredicate.filter(true, espessurasSelecionadas.toArray());
            buttonEliminarFiltroArestas.setEnabled(true);
            vv.repaint();
        }
    });

    buttonEliminarFiltroArestas.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            textFieldFiltroArestas.setText("");
            espessurasSelecionadas = new ArrayList<Object>();
            myEdgeDisplayPredicate.filter(false, espessurasSelecionadas.toArray());
            vv.repaint();
        }
    });

    JPanel p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.LEFT));

    // [inicio] acrescimo dos botoes de zoom
    JButton mais = new JButton();
    mais.setToolTipText("Ampliar");
    mais.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
    mais.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton menos = new JButton();
    menos.setToolTipText("Reduzir");
    menos.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
    menos.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });
    // [fim] acrescimo dos botoes de zoom

    final Color[] cores = { Color.BLACK, Color.BLUE, Color.CYAN, Color.DARK_GRAY, Color.GRAY, Color.GREEN,
            Color.MAGENTA, Color.ORANGE, Color.RED };

    JButton agrupamento = new JButton("Agrupar");
    agrupamento.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            clusterAndRecolor(new SubLayoutDecorator(new FRLayout(graph)), 1, cores, true);
            vv.validate();
            vv.repaint();
        }
    });

    p.add(mais);
    p.add(menos);
    p.add(zoomer);
    p.add(labelFiltroArestas);
    p.add(textFieldFiltroArestas);
    p.add(buttonFiltroArestas);
    p.add(buttonEliminarFiltroArestas);
    p.add(agrupamento);

    frame.getContentPane().add(p, BorderLayout.NORTH);
    frame.setSize(900, 600);
    frame.setVisible(true);
}

From source file:nl.detoren.ijsco.ui.Mainscreen.java

public JPanel createDeelnemersPanel() {
    JPanel panel = new JPanel(false);
    panel.setBackground(Color.BLACK);
    //panel.setLayout(new GridLayout(1, 0));
    panel.setLayout(new BorderLayout());
    JPanel innerPanel = new JPanel();
    JLabel lbAanwezig = new JLabel("Deelnemers: ");
    innerPanel.add(lbAanwezig, BorderLayout.NORTH);
    tfAanwezig = new JLabel(Integer.toString(status.deelnemers.aantalAanwezig()), 10);
    innerPanel.add(tfAanwezig, BorderLayout.NORTH);
    //innerPanel.setLayout(new GridLayout(1, 0));
    innerPanel.add(new JLabel("Naam:"), BorderLayout.NORTH);
    JTextField deelnemer = new JTextField(15);
    ArrayList<String> words = new ArrayList<>();
    if (status.OSBOSpelers != null) {
        for (Speler s : status.OSBOSpelers.values()) {
            words.add(s.getNaam().trim());
            words.add(Integer.toString(s.getKnsbnummer()));
        }//from   www  .j a v a 2 s .c o m
    }
    @SuppressWarnings("unused")
    Suggesties suggesties = new Suggesties(deelnemer, this, words, 2);
    innerPanel.add(deelnemer, BorderLayout.NORTH);
    deelnemer.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            actieVoegSpelerToe(deelnemer.getText().trim());
            deelnemer.setText("");
        }
    });

    JButton btVoegToe = new JButton("Voeg toe");
    btVoegToe.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            actieVoegSpelerToe(deelnemer.getText().trim());
            deelnemer.setText("");
        }
    });
    innerPanel.add(btVoegToe);
    panel.add(innerPanel);
    // panel_deelnemers.add(new JLabel("Deelnemers IJSCO toernooi"));
    deelnemersModel = new DeelnemersModel(panel, status.deelnemers);
    JTable deelnemersTabel = new JTable(deelnemersModel) {
        private static final long serialVersionUID = -8293073016982337108L;

        @Override
        public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
            Component c = super.prepareRenderer(renderer, row, column);
            DeelnemersModel model = (DeelnemersModel) getModel();
            // Tooltip
            if (c instanceof JComponent) {
                ((JComponent) c)
                        .setToolTipText(model.getToolTip(convertRowIndexToModel(row), column).toString());
            }

            // Alternate row color
            if (!isRowSelected(row)) {
                c.setBackground(row % 2 == 0 ? Color.WHITE : Color.LIGHT_GRAY);
            }

            // Highlight overruled entries
            if (status.deelnemers.get(convertRowIndexToModel(row)).isOverruleNaam()
                    || status.deelnemers.get(convertRowIndexToModel(row)).isOverruleNaam()) {
                c.setForeground(Color.BLUE);
            } else {
                c.setForeground(Color.BLACK);
            }
            return c;
        }
    };

    deelnemersTabel.getModel().addTableModelListener(new TableModelListener() {

        @Override
        public void tableChanged(TableModelEvent arg0) {
            status.groepen = null;
            status.schemas = null;
            status.schema = null;
            groepenText.setText("");
            schemaModel.setSchemas(null);
            schemaModel.fireTableDataChanged();
            if (status.deelnemers != null && tfAanwezig != null) {
                tfAanwezig.setText(Integer.toString(status.deelnemers.aantalAanwezig()));
            }
            panel.repaint();
        }

    });

    deelnemersTabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            logger.log(Level.INFO, "MouseEvent on table fired, type : " + e.toString());
            logger.log(Level.INFO, "Popup trigger? : " + e.isPopupTrigger());
            if (e.isPopupTrigger()) {
                int row = deelnemersTabel.rowAtPoint(e.getPoint());
                JPopupMenu popup = new JPopupMenu();
                JMenuItem menuItem = new JMenuItem("Bewerk speler");
                menuItem.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        logger.log(Level.INFO,
                                "Bewerk Speler  : " + deelnemersTabel.convertRowIndexToModel(row));
                        Speler s = status.deelnemers.get(deelnemersTabel.convertRowIndexToModel(row));
                        BewerkSpelerDialoog rd = new BewerkSpelerDialoog(new JFrame(), "Bewerk Speler", s,
                                deelnemersModel);
                        rd.addWindowListener(new WindowAdapter() {
                            @Override
                            public void windowClosed(WindowEvent e) {
                                System.out.println("closing...");
                            }

                        });
                        rd.setVisible(true);
                    }

                });
                popup.add(menuItem);

                menuItem = new JMenuItem("Verwijder Speler");
                popup.add(menuItem);
                menuItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        logger.log(Level.INFO,
                                "Verwijder Speler  : " + deelnemersTabel.convertRowIndexToModel(row));
                        Speler s = status.deelnemers.get(deelnemersTabel.convertRowIndexToModel(row));
                        status.deelnemers.remove(s);
                        deelnemersModel.fireTableDataChanged();
                    }
                });
                popup.show(e.getComponent(), e.getX(), e.getY());

            }
        }
    });

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setViewportView(deelnemersTabel);
    innerPanel.add(scrollPane, BorderLayout.CENTER);

    TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(deelnemersModel);
    deelnemersTabel.setRowSorter(sorter);

    innerPanel.add(new JLabel("Filter op : "));
    JTextField tfFilter = new JTextField(10);
    tfFilter.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            String text = tfFilter.getText();
            logger.log(Level.INFO, "Filter tabel op : " + text);
            if (text.length() == 0) {
                sorter.setRowFilter(null);
            } else {
                sorter.setRowFilter(RowFilter.regexFilter("(?i)" + text));
            }
        }
    });
    innerPanel.add(tfFilter);
    JButton btPasToe = new JButton("Apply");
    btPasToe.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            String text = tfFilter.getText();
            logger.log(Level.INFO, "Filter tabel op : " + text);
            if (text.length() == 0) {
                sorter.setRowFilter(null);
            } else {
                sorter.setRowFilter(RowFilter.regexFilter("(?i)" + text));
            }
        }
    });
    innerPanel.add(btPasToe);
    JButton btWis = new JButton("Wis");
    btWis.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            tfFilter.setText("");
            logger.log(Level.INFO, "Wis filter");
            sorter.setRowFilter(null);
        }
    });
    innerPanel.add(btWis);

    Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(0), 30);
    Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(1), 55);
    Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(2), 170);
    Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(3), 40);
    Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(4), 40);
    Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(5), 30);
    Utils.fixedComponentSize(scrollPane, 400, 580);
    return panel;
}

From source file:nl.tudelft.goal.SimpleIDE.FilePanel.java

private JPopupMenu createPopupMenu() throws IllegalAccessException, InstantiationException {
    JPopupMenu popup = new JPopupMenu();
    popup.add(new JMenuItem(ActionFactory.getAction(EditAction.class)));
    popup.add(new JMenuItem(ActionFactory.getAction(SaveFileAction.class)));
    popup.add(new JMenuItem(ActionFactory.getAction(ReloadFileAction.class)));
    popup.add(new JMenuItem(ActionFactory.getAction(CloseAndRemoveAction.class)));
    popup.add(new JMenuItem(ActionFactory.getAction(RenameAction.class)));
    popup.add(new JSeparator());
    popup.add(new JMenuItem(ActionFactory.getAction(OpenFileAction.class)));
    popup.add(new JMenuItem(ActionFactory.getAction(NewFileAction.class)));
    popup.add(new JMenuItem(ActionFactory.getAction(DeleteAction.class)));
    popup.add(new JSeparator());
    popup.add(new JMenuItem(ActionFactory.getAction(RunAction.class)));
    popup.add(new JSeparator());
    popup.add(new JMenuItem(ActionFactory.getAction(QuitAction.class)));
    return popup;

}

From source file:nz.ac.massey.cs.gql4jung.browser.ResultBrowser.java

private void initPopupMenu() {
    popup = new JPopupMenu();
    popup.add(this.actRunQuery);
    popup.add(this.actCancelQuery);
    popup.addSeparator();/*from   www  .j  a  v  a  2s. c o m*/
    popup.add(this.actLoadData);
    popup.add(this.actLoadQuery);
    popup.addSeparator();
    popup.add(this.actNextMajorInstance);
    popup.add(this.actPreviousMajorInstance);
    popup.addSeparator();
    popup.add(this.actNextMinorInstance);
    popup.add(this.actPreviousMinorInstance);
    popupListener = new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            showPopup(e);
        }

        public void mouseReleased(MouseEvent e) {
            showPopup(e);
        }

        private void showPopup(MouseEvent e) {
            if (e.isPopupTrigger()) {
                popup.show(e.getComponent(), e.getX(), e.getY());
            }
        }
    };
    this.mainPanel.addMouseListener(popupListener);
}

From source file:nz.govt.natlib.ndha.manualdeposit.bulkupload.BulkUploadQueueManagement.java

public JPopupMenu getBulkUploadMenu() {
    JPopupMenu menu = new JPopupMenu();
    String text = "Cancel job";
    if (theBulkUploadItemsTable.getSelectedRowCount() > 1) {
        text += "s";
    }/*from  www  .  j  av a  2 s. c om*/
    JMenuItem item = new JMenuItem(text);
    item.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            cancelJobs(evt);
        }
    });
    menu.add(item);
    BulkUploadTableModel model = (BulkUploadTableModel) theBulkUploadItemsTable.getModel();
    int noOfErrorJobsSelected = model.getSelectedErrorCount(theBulkUploadItemsTable);
    if (noOfErrorJobsSelected > 0) {
        if (noOfErrorJobsSelected > 1) {
            text = "Resubmit jobs in error";
        } else {
            text = "Resubmit job in error";
        }
        item = new JMenuItem(text);
        item.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                resubmitErrorJobs(evt);
            }
        });
        menu.add(item);
    }
    if (menu == null || menu.getComponentCount() == 0) {
        return null;
    } else {
        return menu;
    }
}