Example usage for javax.swing JOptionPane getComponents

List of usage examples for javax.swing JOptionPane getComponents

Introduction

In this page you can find the example usage for javax.swing JOptionPane getComponents.

Prototype

public Component[] getComponents() 

Source Link

Document

Gets all the components in this container.

Usage

From source file:com.floreantpos.config.ui.TerminalConfigurationView.java

public void restartPOS() {
    JOptionPane optionPane = new JOptionPane(Messages.getString("TerminalConfigurationView.26"), //$NON-NLS-1$
            JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, Application.getApplicationIcon(),
            new String[] { /*Messages.getString("TerminalConfigurationView.28"),*/Messages
                    .getString("TerminalConfigurationView.30") }); //$NON-NLS-1$ //$NON-NLS-2$

    Object[] optionValues = optionPane.getComponents();
    for (Object object : optionValues) {
        if (object instanceof JPanel) {
            JPanel panel = (JPanel) object;
            Component[] components = panel.getComponents();

            for (Component component : components) {
                if (component instanceof JButton) {
                    component.setPreferredSize(new Dimension(100, 80));
                    JButton button = (JButton) component;
                    button.setPreferredSize(PosUIManager.getSize(100, 50));
                }/*from   www.j  a  va  2s  . com*/
            }
        }
    }
    JDialog dialog = optionPane.createDialog(Application.getPosWindow(),
            Messages.getString("TerminalConfigurationView.31")); //$NON-NLS-1$
    dialog.setIconImage(Application.getApplicationIcon().getImage());
    dialog.setLocationRelativeTo(Application.getPosWindow());
    dialog.setVisible(true);
    Object selectedValue = (String) optionPane.getValue();
    if (selectedValue != null) {

        if (selectedValue.equals(Messages.getString("TerminalConfigurationView.28"))) { //$NON-NLS-1$
            try {
                Main.restart();
            } catch (IOException | InterruptedException | URISyntaxException e) {
            }
        } else {
        }
    }

}