Example usage for javax.swing JScrollPane setPreferredSize

List of usage examples for javax.swing JScrollPane setPreferredSize

Introduction

In this page you can find the example usage for javax.swing JScrollPane 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:tvbrowser.ui.mainframe.MainFrame.java

private void showInfoTextMessage(String header, String infoText, int width) {
    JTextArea textArea = new JTextArea(infoText);
    textArea.setEditable(false);//from w  w  w. j  av a 2 s  .  c om
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);

    JScrollPane scrollPane = new JScrollPane(textArea);

    scrollPane.setPreferredSize(new Dimension(width, 150));

    Object[] msg = { header, scrollPane };
    JOptionPane.showMessageDialog(this, msg, Localizer.getLocalization(Localizer.I18N_INFO),
            JOptionPane.INFORMATION_MESSAGE);
}

From source file:ui.panel.UIBucketSelect.java

public void runBucketSelect() {
    Panel p = new Panel();
    Button b = new Button();
    Label l = new Label();

    setLayout(new BorderLayout());

    JPanel pnlInstruction = p.createPanel(Layouts.flow);
    JLabel lblInstruction = l.createLabel("Bucket List");
    pnlInstruction.setBackground(CustomColor.LightBlue.returnColor());
    lblInstruction.setForeground(Color.white);
    lblInstruction.setFont(new Font("San Serif", Font.PLAIN, 18));
    pnlInstruction.add(lblInstruction);//from   w w w.j a  v a2 s  .  c om

    JPanel pnlBucketList = p.createPanel(Layouts.border);

    listBucket.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane scrollBucket = new JScrollPane(listBucket);
    scrollBucket.setPreferredSize(new Dimension(300, 150));
    pnlBucketList.add(scrollBucket, BorderLayout.CENTER);

    JPanel pnlButtons = p.createPanel(Layouts.flow);
    JButton btnBack = b.createButton("Back");
    JButton btnSelectElements = b.createButton("Next");
    JButton btnRefresh = b.createButton("Refresh Bucket List");

    pnlButtons.add(btnBack);
    pnlButtons.add(btnRefresh);
    pnlButtons.add(btnSelectElements);

    add(pnlInstruction, BorderLayout.NORTH);
    add(pnlBucketList, BorderLayout.CENTER);
    add(pnlButtons, BorderLayout.SOUTH);
    setVisible(true);

    btnRefresh.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            getBucketData();
        }
    });
    btnSelectElements.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            SwingWorker<Void, Void> mySwingWorker = new SwingWorker<Void, Void>() {
                @Override
                protected Void doInBackground() throws Exception {

                    int selected = listBucket.getSelectedRow();
                    if (selected == -1) {
                        JOptionPane.showMessageDialog(Data.mainFrame, "Please Select a Bucket", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    } else {
                        Data.bucketID = (int) listBucket.getModel().getValueAt(selected, 0);
                        Data.mainFrame.addPanel(Data.mainFrame.uiLicenseDetail = new UILicenseDetail(),
                                "license");
                        Data.mainFrame.pack();
                        Data.mainFrame.showPanel("license");
                    }
                    return null;
                }
            };

            Window win = SwingUtilities.getWindowAncestor((AbstractButton) e.getSource());
            final JDialog dialog = new JDialog(win, "Loading", ModalityType.APPLICATION_MODAL);

            mySwingWorker.addPropertyChangeListener(new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    if (evt.getPropertyName().equals("state")) {
                        if (evt.getNewValue() == SwingWorker.StateValue.DONE) {
                            dialog.dispose();
                        }
                    }
                }
            });
            mySwingWorker.execute();

            JProgressBar progressBar = new JProgressBar();
            progressBar.setIndeterminate(true);
            JPanel panel = new JPanel(new BorderLayout());
            panel.add(progressBar, BorderLayout.CENTER);
            panel.add(new JLabel("Retrieving Licenses......."), BorderLayout.PAGE_START);
            dialog.add(panel);
            dialog.pack();
            dialog.setBounds(50, 50, 300, 100);
            dialog.setLocationRelativeTo(Data.mainFrame);
            dialog.setVisible(true);
        }
    });
    btnBack.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
            Data.mainFrame.showPanel("inventory");
        }
    });
}

From source file:us.ihmc.codecs.loader.OpenH264Downloader.java

private static void acceptLicenseGUI() {

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    JTextArea license = new JTextArea(getLicenseText());
    license.setEditable(false);/* w ww  . jav a2 s .  c om*/
    license.setLineWrap(true);
    license.setWrapStyleWord(true);
    JScrollPane scroll = new JScrollPane(license);
    scroll.setPreferredSize(new Dimension(500, 500));
    panel.add(scroll);
    panel.add(new JLabel("Do you accept the OpenH264 License?"));

    if (JOptionPane.showOptionDialog(null, panel, "OpenH264 Video Codec provided by Cisco Systems, Inc.",
            JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null) != JOptionPane.YES_OPTION) {
        JOptionPane.showMessageDialog(null, "User did not accept OpenH264 license", "License not accepted",
                JOptionPane.ERROR_MESSAGE);
        System.exit(-1);
    }

}

From source file:us.ihmc.codecs.loader.OpenH264Downloader.java

/**
 * Shows an about dialog for the license with disable button, as per license terms
 *///  w w w.  j ava  2 s.  com
public static void showAboutCiscoDialog() {
    JPanel panel = new JPanel();
    panel.add(new JLabel("OpenH264 Video Codec provided by Cisco Systems, Inc."));
    panel.add(new JLabel("License terms"));

    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    JTextArea license = new JTextArea(getLicenseText());
    license.setEditable(false);
    license.setLineWrap(true);
    license.setWrapStyleWord(true);
    JScrollPane scroll = new JScrollPane(license);
    scroll.setPreferredSize(new Dimension(500, 500));
    panel.add(scroll);

    String[] options = new String[2];

    boolean enabled = isEnabled();
    if (enabled) {
        options[0] = "Disable Cisco OpenH264 plugin";
    } else {
        options[0] = "Enable Cisco OpenH264 plugin";
    }
    options[1] = "Close";

    int res = JOptionPane.showOptionDialog(null, panel, "OpenH264 Video Codec provided by Cisco Systems, Inc.",
            JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, null);

    if (res == 0) {
        if (enabled) {
            deleteOpenH264Library();
        } else {
            loadOpenH264(false);
        }
    }
}