Example usage for javax.swing JFrame isAlwaysOnTop

List of usage examples for javax.swing JFrame isAlwaysOnTop

Introduction

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

Prototype

public final boolean isAlwaysOnTop() 

Source Link

Document

Returns whether this window is an always-on-top window.

Usage

From source file:edu.ku.brc.specify.tasks.subpane.wb.WorkbenchPaneSS.java

/**
 * Shows / Hides the Image Window. //from   w  ww  . j a  v  a  2s .  c o  m
 */
public void setImageFrameVisible(final boolean visible, final JFrame imgFrame, final JButton toolBtn,
        final String ttHelpVisible, final String ttHelpHidden, final String helpContext) {
    if (visible == imgFrame.isVisible()) {
        return;
    }

    if (spreadSheet.getCellEditor() != null) {
        spreadSheet.getCellEditor().stopCellEditing();
    }

    // and add or remove the ListSelectionListener (to avoid loading images when not visible)
    if (!visible) {
        spreadSheet.setTransferHandler(null);

        // hide the image window

        // turn off alwaysOnTop for Swing repaint reasons (prevents a lock up)
        if (imgFrame.isAlwaysOnTop()) {
            imgFrame.setAlwaysOnTop(false);
        }
        // if the image frame is minimized or iconified, set it to fully visible before doing anything else
        if (imgFrame.getState() == Frame.ICONIFIED) {
            imgFrame.setState(Frame.NORMAL);
        }
        toolBtn.setToolTipText(getResourceString(ttHelpVisible));

        spreadSheet.getSelectionModel().removeListSelectionListener(workbenchRowChangeListener);

        // set the image window and the image column invisible
        imgFrame.setVisible(false);
        imageColExt.setVisible(false);
    } else {
        spreadSheet.setTransferHandler(new WBImageTransferable());

        // show the image window

        UIHelper.positionFrameRelativeToTopFrame(imgFrame);

        // when a user hits the "show image" button, for some reason the selection gets nullified
        // so we'll grab it here, then set it at the end of this method

        toolBtn.setToolTipText(getResourceString(ttHelpHidden));

        spreadSheet.getSelectionModel().addListSelectionListener(workbenchRowChangeListener);
        HelpMgr.setHelpID(this, helpContext);

        // set the image window and the image column visible
        imgFrame.setVisible(true);
        imageColExt.setVisible(true);

        // if the image frame is minimized or iconified, set it to fully visible before doing anything else
        if (imgFrame.getState() == Frame.ICONIFIED) {
            imgFrame.setState(Frame.NORMAL);
        }

        showCardImageForSelectedRow();

        // Without this code below the Image Column doesn't get selected
        // when toggling 
        if (currentPanelType == PanelType.Spreadsheet && currentRow != -1) {
            spreadSheet.setRowSelectionInterval(currentRow, currentRow);
            spreadSheet.setColumnSelectionInterval(0, spreadSheet.getColumnCount() - 1);
            spreadSheet.scrollToRow(Math.min(currentRow + 4, model.getRowCount()));
        }

        TableColumn column = spreadSheet.getTableHeader().getColumnModel()
                .getColumn(spreadSheet.getTableHeader().getColumnModel().getColumnCount() - 1);
        column.setCellRenderer(new WbCellRenderer());
        spreadSheet.repaint();
    }
}