Example usage for javax.swing JPopupMenu setLightWeightPopupEnabled

List of usage examples for javax.swing JPopupMenu setLightWeightPopupEnabled

Introduction

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

Prototype

@BeanProperty(bound = false, expert = true, description = "Determines whether lightweight popups are used when possible")
public void setLightWeightPopupEnabled(boolean aFlag) 

Source Link

Document

Sets the value of the lightWeightPopupEnabled property, which by default is true.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JPopupMenu popupMenu = new JPopupMenu();

    boolean lwPopup = popupMenu.isLightWeightPopupEnabled(); // true

    popupMenu.setLightWeightPopupEnabled(false);

}

From source file:view.WorkspacePanel.java

private void btnValidateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnValidateActionPerformed
    if (mainWindow.getOpenedFiles().size() > 1) {
        JPopupMenu popup = new JPopupMenu();
        JMenuItem m = null;/* ww  w . j  a  v a  2  s  . com*/
        ActionListener validateOne = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (!rightPanel.isVisible()) {
                    changeCard(CardEnum.VALIDATE_PANEL, true);
                    startValidationThread();
                } else if (WorkspacePanel.this.status == WorkspacePanel.Status.SIGNING) {
                    String msg = Bundle.getBundle().getString("yes");
                    Object[] options = { Bundle.getBundle().getString("msg.signatureStillNotAppliedCancel1"),
                            Bundle.getBundle().getString("no") };
                    int opt = JOptionPane.showOptionDialog(null, msg, "", JOptionPane.DEFAULT_OPTION,
                            JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
                    if (opt == JOptionPane.YES_OPTION) {
                        status = Status.READY;
                        changeCard(CardEnum.VALIDATE_PANEL, true);
                        startValidationThread();
                    }
                }
            }
        };
        ActionListener validateAll = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                MultipleValidationDialog mvd = new MultipleValidationDialog(mainWindow, true,
                        mainWindow.getOpenedFiles());
                mvd.setLocationRelativeTo(null);
                mvd.setVisible(true);
            }
        };
        int numSigs = CCInstance.getInstance().getNumberOfSignatures(document.getDocumentLocation());
        if (numSigs == 0) {
            m = new JMenuItem(Bundle.getBundle().getString("notSigned"));
            m.addActionListener(validateOne);
            m.setEnabled(false);
            popup.add(m);
        } else {
            m = new JMenuItem(Bundle.getBundle().getString("menuItem.validateOnlyThis"));
            m.addActionListener(validateOne);
            popup.add(m);
        }

        if (mainWindow.getSelectedOpenedFiles().size() > 1
                && mainWindow.getSelectedOpenedFiles().size() < mainWindow.getOpenedFiles().size()) {
            m = new JMenuItem(Bundle.getBundle().getString("menuItem.validateAllSelected"));
            m.addActionListener(validateAll);
            popup.add(m);
            m = new JMenuItem(Bundle.getBundle().getString("menuItem.validateAll"));
            m.addActionListener(validateAll);
            popup.add(m);
        } else {
            m = new JMenuItem(Bundle.getBundle().getString("menuItem.validateAll"));
            m.addActionListener(validateAll);
            popup.add(m);
        }

        popup.setLightWeightPopupEnabled(true);
        popup.show(btnValidate, 0, btnValidate.getHeight());

    } else if (!rightPanel.isVisible()) {
        changeCard(CardEnum.VALIDATE_PANEL, true);
        startValidationThread();
    } else if (WorkspacePanel.this.status == WorkspacePanel.Status.SIGNING) {
        String msg = Bundle.getBundle().getString("msg.signatureStillNotAppliedCancel1");
        Object[] options = { Bundle.getBundle().getString("yes"), Bundle.getBundle().getString("no") };
        int opt = JOptionPane.showOptionDialog(null, msg, "", JOptionPane.DEFAULT_OPTION,
                JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
        if (opt == JOptionPane.YES_OPTION) {
            status = Status.READY;
            changeCard(CardEnum.VALIDATE_PANEL, true);
            startValidationThread();
        } else {
            return;
        }
    }
    removeTempSignature();
}