Example usage for javax.swing JTable equals

List of usage examples for javax.swing JTable equals

Introduction

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

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:jp.massbank.spectrumsearch.SearchPage.java

/**
 * ?//from  ww w .ja v a2s  .  c  o m
 * @param e 
 */
private void recListPopup(MouseEvent e) {
    JTable tbl = null;
    JScrollPane pane = null;
    try {
        tbl = (JTable) e.getSource();
    } catch (ClassCastException cce) {
        pane = (JScrollPane) e.getSource();
        if (pane.equals(queryDbPane)) {
            tbl = queryDbTable;
        } else if (pane.equals(resultPane)) {
            tbl = resultTable;
        }
        if (pane.equals(queryFilePane)) {
            tbl = queryFileTable;
        }
    }
    int rowCnt = tbl.getSelectedRows().length;

    JMenuItem item1 = new JMenuItem("Show Record");
    item1.addActionListener(new PopupShowRecordListener(tbl));
    JMenuItem item2 = new JMenuItem("Multiple Display");
    item2.addActionListener(new PopupMultipleDisplayListener(tbl));

    // ?
    if (tbl.equals(queryFileTable)) {
        item1.setEnabled(false);
        item2.setEnabled(false);
    } else if (rowCnt == 0) {
        item1.setEnabled(false);
        item2.setEnabled(false);
    } else if (rowCnt == 1) {
        item1.setEnabled(true);
        item2.setEnabled(false);
    } else if (rowCnt > 1) {
        item1.setEnabled(false);
        item2.setEnabled(true);
    }

    // ?
    JPopupMenu popup = new JPopupMenu();
    popup.add(item1);
    if (tbl.equals(resultTable)) {
        popup.add(item2);
    }
    popup.show(e.getComponent(), e.getX(), e.getY());
}

From source file:nz.govt.natlib.ndha.manualdeposit.jobmanagement.JobQueueManagement.java

public JPopupMenu getJobQueueMenu(final JTable table) {
    theTableSelected = table;/*from   w  w w .j  av  a2 s .c  o m*/
    final JPopupMenu menu = new JPopupMenu();
    boolean sortAscending = false;
    if (table.equals(theJobQueueRunningTable)) {
        sortAscending = personalSettings.isSortRunningAscending();
    } else if (table.equals(theJobQueuePendingTable)) {
        sortAscending = personalSettings.isSortPendingAscending();
    } else if (table.equals(theJobQueueFailedTable)) {
        sortAscending = personalSettings.isSortFailedAscending();
    } else if (table.equals(theJobQueueDepositedTable)) {
        sortAscending = personalSettings.isSortDepositedAscending();
    } else if (table.equals(theJobQueueInPermanentTable)) {
        sortAscending = personalSettings.isSortCompleteAscending();
    }
    JMenuItem item;
    if (sortAscending) {
        item = new JMenuItem("Sort by date in descending order");
    } else {
        item = new JMenuItem("Sort by date in ascending order");
    }
    item.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(final java.awt.event.ActionEvent evt) {
            resortTable(evt);
        }
    });
    menu.add(item);
    if ((table.equals(theJobQueueRunningTable)) || (table.equals(theJobQueuePendingTable))
            || (table.equals(theJobQueueFailedTable))) {
        StringBuffer text = new StringBuffer();
        text.append("Cancel job");
        if (table.getSelectedRowCount() > 1) {
            text.append('s');
        }
        item = new JMenuItem(text.toString());
        item.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(final java.awt.event.ActionEvent evt) {
                try {
                    cancelJobs(evt);
                } catch (JobQueueException ex) {
                    String message = "Error cancelling jobs";
                    LOG.error(message, ex);
                    mainFrame.showError("An error occurred", message, ex);
                }
            }
        });
        menu.add(item);
        if (table.equals(theJobQueueFailedTable)) {
            text = new StringBuffer();
            text.append("Resubmit job");
            if (table.getSelectedRowCount() > 1) {
                text.append('s');
            }
            item = new JMenuItem(text.toString());
            item.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(final java.awt.event.ActionEvent evt) {
                    resubmitJob(evt);
                }
            });
            menu.add(item);
        }
    }
    if (table.equals(theJobQueueInPermanentTable)) {
        item = new JMenuItem("Clear completed jobs");
        item.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(final java.awt.event.ActionEvent evt) {
                clearFinishedJobs(evt);
            }
        });
        menu.add(item);
    }
    if (menu == null || menu.getComponentCount() == 0) {
        return null;
    } else {
        return menu;
    }
}