Example usage for javax.swing JComboBox isPopupVisible

List of usage examples for javax.swing JComboBox isPopupVisible

Introduction

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

Prototype

public boolean isPopupVisible() 

Source Link

Document

Determines the visibility of the popup.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    String[] items = { "item1", "item2" };
    JComboBox cb = new JComboBox(items);

    // Determine if the menu is visible
    boolean isVisible = cb.isPopupVisible();

}

From source file:com.mirth.connect.client.ui.alert.AlertActionPane.java

private void makeActionTable() {
    actionTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    actionTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    actionTable.getColumnExt(PROTOCOL_COLUMN_NAME).setCellEditor(new MirthComboBoxTableCellEditor(actionTable,
            protocols.keySet().toArray(), 1, false, new ActionListener() {

                @Override//from   w ww.j ava  2 s  .co m
                public void actionPerformed(ActionEvent e) {
                    JComboBox comboBox = (JComboBox) e.getSource();
                    if (comboBox.isPopupVisible()) {
                        PlatformUI.MIRTH_FRAME.setSaveEnabled(true);
                    }
                }

            }));

    actionTable.getColumnExt(PROTOCOL_COLUMN_NAME)
            .setCellRenderer(new MirthComboBoxTableCellRenderer(protocols.keySet().toArray()));

    actionTable.getColumnExt(RECIPIENT_COLUMN_INDEX).setCellRenderer(new RecipientCellRenderer());

    actionTable.getColumnExt(RECIPIENT_COLUMN_NAME).setCellEditor(new RecipientCellEditor());

    actionTable.setRowHeight(UIConstants.ROW_HEIGHT);
    actionTable.setSortable(false);
    actionTable.setOpaque(true);
    actionTable.setDragEnabled(false);
    actionTable.getTableHeader().setReorderingAllowed(false);
    actionTable.setShowGrid(true, true);
    actionTable.setAutoCreateColumnsFromModel(false);

    actionTable.getColumnExt(PROTOCOL_COLUMN_NAME).setMaxWidth(PROTOCOL_COLUMN_WIDTH);
    actionTable.getColumnExt(PROTOCOL_COLUMN_NAME).setMinWidth(PROTOCOL_COLUMN_WIDTH);
    actionTable.getColumnExt(PROTOCOL_COLUMN_NAME).setResizable(false);

    actionTable.getColumnExt(RECIPIENT_COLUMN_NAME).setMinWidth(UIConstants.MIN_WIDTH);
    actionTable.getColumnExt(RECIPIENT_COLUMN_NAME).setResizable(false);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR,
                UIConstants.BACKGROUND_COLOR);
        actionTable.setHighlighters(highlighter);
    }
}

From source file:com.mirth.connect.client.ui.alert.AlertActionPane.java

private void updateActionTable(List<AlertAction> alertActions) {
    // Make sure there aren't any cell editors still active
    TableCellEditor cellEditor = actionTable.getCellEditor();

    if (cellEditor != null) {
        cellEditor.stopCellEditing();// www.j a v a 2  s.co  m
    }

    for (Protocol protocol : protocols.values()) {
        if (protocol.hasOptions()) {
            MirthComboBoxTableCellEditor editor = new MirthComboBoxTableCellEditor(actionTable,
                    protocol.getRecipientNames().toArray(), 1, true, new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                            JComboBox comboBox = (JComboBox) e.getSource();
                            if (comboBox.isPopupVisible() && actionTable.getCellEditor() != null) {
                                actionTable.getCellEditor().stopCellEditing();
                            }
                            PlatformUI.MIRTH_FRAME.setSaveEnabled(true);

                        }

                    });

            editor.setEditable(true);
            editor.getComboBox().setCanEnableSave(false);
            editor.getComboBox().setAutoResizeDropdown(true);

            MirthComboBoxTableCellRenderer renderer = new MirthComboBoxTableCellRenderer(
                    protocol.getRecipientNames().toArray());
            renderer.setEditable(true);

            // Update the recipient column renderer and editor with the current names
            ((RecipientCellRenderer) actionTable.getColumnExt(RECIPIENT_COLUMN_INDEX).getCellRenderer())
                    .setCellRenderer(protocol.getProtocolName(), renderer);
            ((RecipientCellEditor) actionTable.getColumnExt(RECIPIENT_COLUMN_NAME).getCellEditor())
                    .setCellEditor(protocol.getProtocolName(), editor);
        }
    }

    ActionTableModel model = (ActionTableModel) actionTable.getModel();
    model.refreshData(alertActions);
    if (model.getRowCount() == 0) {
        actionTable.clearSelection();
        removeActionButton.setEnabled(false);
    } else {
        actionTable.getSelectionModel().setSelectionInterval(0, 0);
        removeActionButton.setEnabled(true);
    }
}

From source file:com.mirth.connect.client.ui.SettingsPanelResources.java

private void typeComboBoxActionPerformed(ActionEvent evt) {
    JComboBox comboBox = (JComboBox) evt.getSource();
    if (comboBox.isPopupVisible()) {
        int selectedRow = resourceTable.getSelectedRow();
        if (selectedRow >= 0) {
            String type = (String) comboBox.getSelectedItem();

            if (propertiesPanelMap.containsKey(type)) {
                changePropertiesPanel(type);
                ResourceProperties properties = currentPropertiesPanel.getDefaults();
                resourceTable.getModel().setValueAt(properties, selectedRow, PROPERTIES_COLUMN);
                currentPropertiesPanel.setProperties(properties);
                getFrame().setSaveEnabled(true);
            }/*from   w  w w .j ava  2  s. c o  m*/
        }
    }
}