Example usage for javax.swing JOptionPane setPreferredSize

List of usage examples for javax.swing JOptionPane setPreferredSize

Introduction

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

Prototype

@BeanProperty(preferred = true, description = "The preferred size of the component.")
public void setPreferredSize(Dimension preferredSize) 

Source Link

Document

Sets the preferred size of this component.

Usage

From source file:org.broad.igv.track.TrackMenuUtils.java

public static JMenuItem getRemoveMenuItem(final Collection<Track> selectedTracks) {

    boolean multiple = selectedTracks.size() > 1;

    JMenuItem item = new JMenuItem("Remove Track" + (multiple ? "s" : ""));
    item.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            if (selectedTracks.isEmpty()) {
                return;
            }//from  w w  w . j ava  2  s.  c o m

            StringBuffer buffer = new StringBuffer();
            for (Track track : selectedTracks) {
                buffer.append("\n\t");
                buffer.append(track.getName());
            }
            String deleteItems = buffer.toString();

            JTextArea textArea = new JTextArea();
            textArea.setEditable(false);
            JScrollPane scrollPane = new JScrollPane(textArea);
            textArea.setText(deleteItems);

            JOptionPane optionPane = new JOptionPane(scrollPane, JOptionPane.PLAIN_MESSAGE,
                    JOptionPane.YES_NO_OPTION);
            optionPane.setPreferredSize(new Dimension(550, 500));
            JDialog dialog = optionPane.createDialog(IGV.getMainFrame(), "Remove The Following Tracks");
            dialog.setVisible(true);

            Object choice = optionPane.getValue();
            if ((choice == null) || (JOptionPane.YES_OPTION != ((Integer) choice).intValue())) {
                return;
            }

            IGV.getInstance().removeTracks(selectedTracks);
            IGV.getInstance().doRefresh();
        }
    });
    return item;
}