Example usage for javax.swing JPopupMenu add

List of usage examples for javax.swing JPopupMenu add

Introduction

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

Prototype

public JMenuItem add(Action a) 

Source Link

Document

Appends a new menu item to the end of the menu which dispatches the specified Action object.

Usage

From source file:org.yccheok.jstock.gui.IndicatorPanel.java

private JPopupMenu getJListPopupMenu() {
    final JPopupMenu popup = new JPopupMenu();
    javax.swing.JMenuItem menuItem = new JMenuItem(GUIBundle.getString("New..."),
            this.getImageIcon("/images/16x16/filenew.png"));
    menuItem.addActionListener(new ActionListener() {
        @Override/*from   w w  w. j av  a 2s . co  m*/
        public void actionPerformed(ActionEvent evt) {
            New();
        }
    });
    popup.add(menuItem);
    menuItem = new JMenuItem(GUIBundle.getString("Save"), this.getImageIcon("/images/16x16/filesave.png"));
    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            Save(true);
        }
    });
    popup.add(menuItem);
    popup.addSeparator();

    menuItem = new JMenuItem(GUIBundle.getString("Install..."),
            this.getImageIcon("/images/16x16/download.png"));
    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            Install();
        }
    });
    popup.add(menuItem);

    if (isIndicatorDatabaseVisibleAndSelected() || isModuleDatabaseVisibleAndSelected()) {
        menuItem = new JMenuItem(GUIBundle.getString("Export..."),
                this.getImageIcon("/images/16x16/upload.png"));
        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                Export();
            }
        });
        popup.add(menuItem);
        popup.addSeparator();
        menuItem = new JMenuItem(GUIBundle.getString("Rename..."), this.getImageIcon("/images/16x16/edit.png"));
        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                Rename();
            }
        });
        popup.add(menuItem);
        menuItem = new JMenuItem(GUIBundle.getString("Delete"),
                this.getImageIcon("/images/16x16/editdelete.png"));
        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                Delete(true);
            }
        });
        popup.add(menuItem);
    }
    return popup;
}

From source file:org.yccheok.jstock.gui.IndicatorScannerJPanel.java

private JPopupMenu getMyJTablePopupMenu() {
    JPopupMenu popup = new JPopupMenu();

    final JStock m = JStock.instance();

    javax.swing.JMenuItem menuItem = new JMenuItem(java.util.ResourceBundle
            .getBundle("org/yccheok/jstock/data/gui").getString("IndicatorScannerJPanel_History..."),
            this.getImageIcon("/images/16x16/strokedocker.png"));

    menuItem.addActionListener(new ActionListener() {
        @Override//from   w w  w. j  a va 2s. c o m
        public void actionPerformed(ActionEvent evt) {
            int rows[] = jTable1.getSelectedRows();
            final IndicatorTableModel tableModel = (IndicatorTableModel) jTable1.getModel();

            for (int row : rows) {
                final int modelIndex = jTable1.convertRowIndexToModel(row);
                final Indicator indicator = tableModel.getIndicator(modelIndex);
                if (indicator != null) {
                    m.displayHistoryChart(indicator.getStock());
                }
            }
        }
    });

    popup.add(menuItem);

    menuItem = new JMenuItem(java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui")
            .getString("IndicatorScannerJPanel_News..."), this.getImageIcon("/images/16x16/news.png"));

    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            int rows[] = jTable1.getSelectedRows();
            final IndicatorTableModel tableModel = (IndicatorTableModel) jTable1.getModel();

            for (int row : rows) {
                final int modelIndex = jTable1.convertRowIndexToModel(row);
                final Indicator indicator = tableModel.getIndicator(modelIndex);
                if (indicator != null) {
                    m.displayStockNews(indicator.getStock());
                }
            }
        }
    });

    popup.add(menuItem);

    popup.addSeparator();

    menuItem = new JMenuItem(GUIBundle.getString("IndicatorScannerJPanel_AddToRealTimeInfo"),
            this.getImageIcon("/images/16x16/add.png"));

    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            int rows[] = jTable1.getSelectedRows();
            final IndicatorTableModel tableModel = (IndicatorTableModel) jTable1.getModel();

            for (int row : rows) {
                final int modelIndex = jTable1.convertRowIndexToModel(row);
                final Indicator indicator = tableModel.getIndicator(modelIndex);
                if (indicator != null) {
                    m.addStockToTable(indicator.getStock());
                }
            }
        }
    });

    popup.add(menuItem);

    if (jTable1.getSelectedRowCount() == 1) {
        popup.addSeparator();

        menuItem = new JMenuItem(GUIBundle.getString("IndicatorScannerJPanel_Buy..."),
                this.getImageIcon("/images/16x16/inbox.png"));

        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                final int row = jTable1.getSelectedRow();
                final int modelIndex = jTable1.getRowSorter().convertRowIndexToModel(row);
                final IndicatorTableModel tableModel = (IndicatorTableModel) jTable1.getModel();
                final Indicator indicator = tableModel.getIndicator(modelIndex);
                final Stock stock = indicator.getStock();
                JStock.instance().getPortfolioManagementJPanel().showNewBuyTransactionJDialog(stock,
                        stock.getLastPrice(), false);
            }
        });

        popup.add(menuItem);
    }

    return popup;
}

From source file:org.yccheok.jstock.gui.JStock.java

private JPopupMenu getMyJTablePopupMenu() {
    final JPopupMenu popup = new JPopupMenu();
    final TableModel tableModel = jTable1.getModel();

    javax.swing.JMenuItem menuItem = new JMenuItem(
            java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui").getString("MainFrame_History..."),
            this.getImageIcon("/images/16x16/strokedocker.png"));

    menuItem.addActionListener(new ActionListener() {
        @Override//from w ww  .  j a  v a2  s  .c o m
        public void actionPerformed(ActionEvent evt) {
            displayHistoryCharts();
        }
    });

    popup.add(menuItem);

    menuItem = new JMenuItem(
            java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui").getString("MainFrame_News..."),
            this.getImageIcon("/images/16x16/news.png"));
    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            displayStocksNews();
        }
    });
    popup.add(menuItem);

    popup.addSeparator();

    if (jTable1.getSelectedRowCount() == 1) {
        menuItem = new JMenuItem(
                java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui").getString("MainFrame_Buy..."),
                this.getImageIcon("/images/16x16/inbox.png"));

        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                final int row = jTable1.getSelectedRow();
                final int modelIndex = jTable1.getRowSorter().convertRowIndexToModel(row);
                final Stock stock = ((StockTableModel) tableModel).getStock(modelIndex);

                // We have a real nasty bug here. We retrieve stock information through stock code.
                // When we receive stock information, we update all its particular information, including stock
                // symbol. Here is the catch, the latest updated stock symbol (stock.getSymbol), may not be the
                // same as stock symbol found in stock database. If we pass the stock symbol which is not found
                // in stock database to portfolio, something can go wrong. This is because portfolio rely heavily
                // on symbol <-> code conversion. Hence, instead of using stock.getSymbol, we prefer to get the
                // symbol out from stock database. This marks the close of the following reported bugs :
                //
                // [2800598] buyportfolio.xml file not updated with code symbol
                // [2790218] User unable to add new buy transaction in Spain
                //
                // Say no to : portfolioManagementJPanel.showNewBuyTransactionJDialog(stock.symbol, stock.getLastPrice(), false);
                portfolioManagementJPanel.showNewBuyTransactionJDialog(stock, stock.getLastPrice(), false);
            }
        });

        popup.add(menuItem);

        popup.addSeparator();
    }

    menuItem = new JMenuItem(
            java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui").getString("MainFrame_Delete"),
            this.getImageIcon("/images/16x16/editdelete.png"));

    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            JStock.this.deteleSelectedTableRow();
        }
    });

    popup.add(menuItem);

    return popup;
}

From source file:org.yccheok.jstock.gui.MainFrame.java

private JPopupMenu getMyJTablePopupMenu() {
    final JPopupMenu popup = new JPopupMenu();
    final TableModel tableModel = jTable1.getModel();

    javax.swing.JMenuItem menuItem = new JMenuItem(
            java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui").getString("MainFrame_History..."),
            this.getImageIcon("/images/16x16/strokedocker.png"));

    menuItem.addActionListener(new ActionListener() {
        @Override/*from  w  ww .  j a v a2  s .  c  o  m*/
        public void actionPerformed(ActionEvent evt) {
            int rows[] = jTable1.getSelectedRows();
            final StockTableModel tableModel = (StockTableModel) jTable1.getModel();

            for (int row : rows) {
                final int modelIndex = jTable1.getRowSorter().convertRowIndexToModel(row);
                Stock stock = tableModel.getStock(modelIndex);
                displayHistoryChart(stock);
            }
        }
    });

    popup.add(menuItem);

    popup.addSeparator();

    if (jTable1.getSelectedRowCount() == 1) {
        menuItem = new JMenuItem(
                java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui").getString("MainFrame_Buy..."),
                this.getImageIcon("/images/16x16/inbox.png"));

        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                final int row = jTable1.getSelectedRow();
                final int modelIndex = jTable1.getRowSorter().convertRowIndexToModel(row);
                final Stock stock = ((StockTableModel) tableModel).getStock(modelIndex);

                // We have a real nasty bug here. We retrieve stock information through stock code.
                // When we receive stock information, we update all its particular information, including stock
                // symbol. Here is the catch, the latest updated stock symbol (stock.getSymbol), may not be the
                // same as stock symbol found in stock database. If we pass the stock symbol which is not found
                // in stock database to portfolio, something can go wrong. This is because portfolio rely heavily
                // on symbol <-> code conversion. Hence, instead of using stock.getSymbol, we prefer to get the
                // symbol out from stock database. This marks the close of the following reported bugs :
                //
                // [2800598] buyportfolio.xml file not updated with code symbol
                // [2790218] User unable to add new buy transaction in Spain
                //
                // Say no to : portfolioManagementJPanel.showNewBuyTransactionJDialog(stock.symbol, stock.getLastPrice(), false);
                portfolioManagementJPanel.showNewBuyTransactionJDialog(stock, stock.getLastPrice(), false);
            }
        });

        popup.add(menuItem);

        popup.addSeparator();
    }

    menuItem = new JMenuItem(
            java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui").getString("MainFrame_Delete"),
            this.getImageIcon("/images/16x16/editdelete.png"));

    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            MainFrame.this.deteleSelectedTableRow();
        }
    });

    popup.add(menuItem);

    return popup;
}

From source file:org.yccheok.jstock.gui.portfolio.DividendSummaryJDialog.java

private JPopupMenu getMyJTablePopupMenu() {
    final JPopupMenu popup = new JPopupMenu();

    javax.swing.JMenuItem menuItem = new JMenuItem(
            java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui").getString("DividendSummary_New"),
            new javax.swing.ImageIcon(getClass().getResource("/images/16x16/filenew.png")));

    menuItem.addActionListener(new ActionListener() {
        @Override//from   w  w w .  j a  v  a2 s  .  com
        public void actionPerformed(ActionEvent e) {
            addNewDividend();
        }
    });

    popup.add(menuItem);

    final Commentable commentable = getSelectedCommentable();
    final String text = this.getSelectedSecondColumnString();
    if (commentable != null && text != null) {
        popup.addSeparator();

        menuItem = new JMenuItem(
                java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui")
                        .getString("DividendSummary_Note..."),
                new javax.swing.ImageIcon(getClass().getResource("/images/16x16/sticky.png")));

        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                showCommentJDialog(commentable, MessageFormat
                        .format(GUIBundle.getString("DividendSummaryJDialog_NoteFor_template"), text));
            }
        });

        popup.add(menuItem);
    }

    if (jTable1.getSelectedRowCount() >= 1) {
        popup.addSeparator();

        menuItem = new JMenuItem(
                java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui")
                        .getString("DividendSummaryJDialog_Delete"),
                new javax.swing.ImageIcon(getClass().getResource("/images/16x16/editdelete.png")));

        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                deleteSelectedDividend();
                jLabel2.setText(getDividendSummaryText());
            }
        });

        popup.add(menuItem);
    }

    return popup;
}

From source file:org.yccheok.jstock.gui.PortfolioManagementJPanel.java

private JPopupMenu getSellTreeTablePopupMenu() {
    final List<Transaction> transactions = getSelectedTransactions(this.sellTreeTable);

    JPopupMenu popup = new JPopupMenu();

    JMenuItem menuItem = null;//from   w  ww  .j a  v  a2s.  com

    menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagementJPanel_Cash..."),
            this.getImageIcon("/images/16x16/money.png"));

    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            showDepositSummaryJDialog();
        }
    });

    popup.add(menuItem);

    menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Dividend..."),
            this.getImageIcon("/images/16x16/money2.png"));

    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            showDividendSummaryJDialog();
        }
    });

    popup.add(menuItem);

    popup.addSeparator();

    if (transactions.size() == 1) {
        menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Edit..."),
                this.getImageIcon("/images/16x16/edit.png"));

        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                PortfolioManagementJPanel.this.showEditTransactionJDialog(transactions.get(0));
            }
        });

        popup.add(menuItem);
    }

    final Commentable commentable = getSelectedCommentable(this.sellTreeTable);
    final String tmp = getSelectedFirstColumnString(this.sellTreeTable);
    if (commentable != null && tmp != null) {
        menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Note..."),
                this.getImageIcon("/images/16x16/sticky.png"));

        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                final String template = GUIBundle.getString("PortfolioManagementJPanel_NoteFor_template");
                final String title = MessageFormat.format(template, tmp);
                PortfolioManagementJPanel.this.showCommentJDialog(commentable, title);
            }
        });

        popup.add(menuItem);

        popup.addSeparator();
    } else if (transactions.size() == 1) {
        popup.addSeparator();
    }

    menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_InvestmentChart..."),
            this.getImageIcon("/images/16x16/graph.png"));

    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            showChashFlowChartJDialog();
        }
    });

    popup.add(menuItem);

    menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagementJPanel_DividendChart"),
            this.getImageIcon("/images/16x16/chart.png"));

    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            PortfolioManagementJPanel.this.showDividendSummaryBarChartJDialog();
        }
    });

    popup.add(menuItem);

    menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Summary..."),
            this.getImageIcon("/images/16x16/pie_chart.png"));

    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            PortfolioManagementJPanel.this.showSellPortfolioChartJDialog();
        }
    });

    popup.add(menuItem);

    if (isOnlyTreeTableRootBeingSelected(sellTreeTable) == false && (sellTreeTable.getSelectedRow() > 0)) {
        final JStock m = JStock.instance();

        menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_History..."),
                this.getImageIcon("/images/16x16/strokedocker.png"));

        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                List<Stock> stocks = getSelectedStocks(sellTreeTable);

                for (Stock stock : stocks) {
                    m.displayHistoryChart(stock);
                }
            }
        });

        popup.addSeparator();

        popup.add(menuItem);

        menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_News..."),
                this.getImageIcon("/images/16x16/news.png"));

        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                List<Stock> stocks = getSelectedStocks(sellTreeTable);

                for (Stock stock : stocks) {
                    m.displayStockNews(stock);
                }
            }
        });

        popup.add(menuItem);

        popup.addSeparator();

        menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Delete"),
                this.getImageIcon("/images/16x16/editdelete.png"));

        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                PortfolioManagementJPanel.this.deteleSelectedTreeTableRow();
            }
        });

        popup.add(menuItem);
    }

    return popup;
}

From source file:org.yccheok.jstock.gui.PortfolioManagementJPanel.java

private JPopupMenu getBuyTreeTablePopupMenu() {
    JPopupMenu popup = new JPopupMenu();

    JMenuItem menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Buy..."),
            this.getImageIcon("/images/16x16/inbox.png"));

    menuItem.addActionListener(new ActionListener() {
        @Override//from w w  w.  j  a  v  a2s  . c  o  m
        public void actionPerformed(ActionEvent evt) {
            List<Stock> stocks = getSelectedStocks();
            if (stocks.size() == 1) {
                PortfolioManagementJPanel.this.showNewBuyTransactionJDialog(stocks.get(0),
                        PortfolioManagementJPanel.this.getStockPrice(stocks.get(0).code), true);
            } else {
                PortfolioManagementJPanel.this.showNewBuyTransactionJDialog(org.yccheok.jstock.engine.Utils
                        .getEmptyStock(Code.newInstance(""), Symbol.newInstance("")), 0.0, true);
            }
        }
    });

    popup.add(menuItem);

    final List<Transaction> transactions = getSelectedTransactions(this.buyTreeTable);
    final List<Stock> stocks = this.getSelectedStocks(this.buyTreeTable);

    if (transactions.size() > 0 && stocks.size() == 1) {
        menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Sell..."),
                this.getImageIcon("/images/16x16/outbox.png"));

        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                PortfolioManagementJPanel.this.showNewSellTransactionJDialog(transactions);
            }
        });

        popup.add(menuItem);
    }

    popup.addSeparator();

    menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagementJPanel_Cash..."),
            this.getImageIcon("/images/16x16/money.png"));

    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            showDepositSummaryJDialog();
        }
    });

    popup.add(menuItem);

    menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Dividend..."),
            this.getImageIcon("/images/16x16/money2.png"));

    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            showDividendSummaryJDialog();
        }
    });

    popup.add(menuItem);

    popup.addSeparator();

    boolean needToAddSeperator = false;

    if (transactions.size() == 1) {
        menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Edit..."),
                this.getImageIcon("/images/16x16/edit.png"));

        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                PortfolioManagementJPanel.this.showEditTransactionJDialog(transactions.get(0));
            }
        });

        popup.add(menuItem);
        needToAddSeperator = true;
    }

    final Commentable commentable = getSelectedCommentable(this.buyTreeTable);
    final String tmp = getSelectedFirstColumnString(this.buyTreeTable);
    if (commentable != null && tmp != null) {
        menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Note..."),
                this.getImageIcon("/images/16x16/sticky.png"));

        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                final String template = GUIBundle.getString("PortfolioManagementJPanel_NoteFor_template");
                final String title = MessageFormat.format(template, tmp);
                PortfolioManagementJPanel.this.showCommentJDialog(commentable, title);
            }
        });

        popup.add(menuItem);
        needToAddSeperator = true;
    }

    // Split or merge only allowed, if there is one and only one stock
    // being selected.
    final List<Stock> selectedStocks = this.getSelectedStocks();
    if (selectedStocks.size() == 1) {
        menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagementJPanel_SplitOrMerge"),
                this.getImageIcon("/images/16x16/merge.png"));

        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                PortfolioManagementJPanel.this
                        .showSplitOrMergeJDialog(StockInfo.newInstance(selectedStocks.get(0)));
            }
        });

        popup.add(menuItem);
        needToAddSeperator = true;
    }

    if (needToAddSeperator) {
        popup.addSeparator();
    }

    menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_InvestmentChart..."),
            this.getImageIcon("/images/16x16/graph.png"));

    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            showChashFlowChartJDialog();
        }
    });

    popup.add(menuItem);

    menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagementJPanel_DividendChart"),
            this.getImageIcon("/images/16x16/chart.png"));

    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            PortfolioManagementJPanel.this.showDividendSummaryBarChartJDialog();
        }
    });

    popup.add(menuItem);

    menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Summary..."),
            this.getImageIcon("/images/16x16/pie_chart.png"));

    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            PortfolioManagementJPanel.this.showBuyPortfolioChartJDialog();
        }
    });

    popup.add(menuItem);

    if (isOnlyTreeTableRootBeingSelected(buyTreeTable) == false && (buyTreeTable.getSelectedRow() > 0)) {
        final JStock m = JStock.instance();

        menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_History..."),
                this.getImageIcon("/images/16x16/strokedocker.png"));

        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                List<Stock> stocks = getSelectedStocks(buyTreeTable);

                for (Stock stock : stocks) {
                    m.displayHistoryChart(stock);
                }
            }
        });

        popup.addSeparator();

        popup.add(menuItem);

        menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_News..."),
                this.getImageIcon("/images/16x16/news.png"));

        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                List<Stock> stocks = getSelectedStocks(buyTreeTable);

                for (Stock stock : stocks) {
                    m.displayStockNews(stock);
                }
            }
        });

        popup.add(menuItem);

        popup.addSeparator();

        menuItem = new JMenuItem(GUIBundle.getString("PortfolioManagement_Delete"),
                this.getImageIcon("/images/16x16/editdelete.png"));

        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                PortfolioManagementJPanel.this.deteleSelectedTreeTableRow();
            }
        });

        popup.add(menuItem);
    }

    return popup;
}

From source file:org.yccheok.jstock.gui.StockDatabaseJDialog.java

private JPopupMenu getMyJTablePopupMenu(boolean newMenuItemOnly) {
    final JPopupMenu popup = new JPopupMenu();

    javax.swing.JMenuItem menuItem = new JMenuItem("New",
            new javax.swing.ImageIcon(getClass().getResource("/images/16x16/filenew.png")));

    menuItem.addActionListener(new ActionListener() {
        @Override//w  w w .j a  va  2 s .  c  om
        public void actionPerformed(ActionEvent e) {
            addNewStockInfo();
        }
    });

    popup.add(menuItem);

    if (newMenuItemOnly) {
        /* Single menu item only. */
        return popup;
    }

    if (jTable2.getSelectedRowCount() >= 1) {
        popup.addSeparator();

        menuItem = new JMenuItem("Delete",
                new javax.swing.ImageIcon(getClass().getResource("/images/16x16/editdelete.png")));

        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                deleteSelectedUserDefinedDatabase();
            }
        });

        popup.add(menuItem);
    }

    return popup;
}

From source file:org.zaproxy.zap.extension.openapi.ImportFromUrlDialog.java

public JTextField addContextMenu(final JTextField field) {
    JPopupMenu jPopupMenu = new JPopupMenu();
    String actionName = Constant.messages.getString(MESSAGE_PREFIX + "pasteaction");
    @SuppressWarnings("serial")
    Action pasteAction = new AbstractAction(actionName) {

        public void actionPerformed(ActionEvent e) {
            field.paste();/*  w  ww  . j a  v a 2s .com*/
        }
    };
    JMenuItem paste = new JMenuItem(pasteAction);
    jPopupMenu.add(paste);
    field.setComponentPopupMenu(jPopupMenu);
    return field;
}

From source file:picocash.components.mode.buttons.AccountModeButton.java

@Override
protected void fillPopupMenu(JPopupMenu popupMenu) {
    if (accounts.size() > 0) {
        for (Account account : accounts) {
            log.debug(account);/*  ww w.j  a v  a  2s  .co  m*/
            final AccountMenuItem accountMenuItem = new AccountMenuItem(account);

            accountMenuItem.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent arg0) {
                    setSelectedAccount(accountMenuItem.getAccount());
                }
            });
            popupMenu.add(accountMenuItem);
        }
    } else {
        popupMenu.add("no accounts available");
    }
}