Example usage for javax.swing JPanel getPreferredSize

List of usage examples for javax.swing JPanel getPreferredSize

Introduction

In this page you can find the example usage for javax.swing JPanel getPreferredSize.

Prototype

@Transient
public Dimension getPreferredSize() 

Source Link

Document

If the preferredSize has been set to a non-null value just returns it.

Usage

From source file:IteratorTest.java

protected JPanel getCountPanel() {
    JPanel panel = new JPanel();
    JLabel label = new JLabel("Count:", JLabel.RIGHT);
    panel.add(label);//  www .j a  va  2 s .c  o  m

    Dimension size = panel.getPreferredSize();
    size.width = Math.min(size.width, 100);

    refreshButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            refreshDisplay();
        }
    });
    panel.add(refreshButton);
    return panel;
}

From source file:de.atomfrede.tools.evalutation.ui.ExceptionDialog.java

public JComponent createDetailsPanel() {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    exception.printStackTrace(pw);//w  w w  .  j  av  a2 s  .  c o m
    JTextArea textArea = new JTextArea(sw.toString());
    // textArea.setRows(10);

    JLabel label = new JLabel("Details:");

    JPanel panel = new JPanel(new BorderLayout(6, 6));
    panel.add(new JScrollPane(textArea));
    panel.add(label, BorderLayout.BEFORE_FIRST_LINE);
    label.setLabelFor(textArea);
    panel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));

    setSize((int) panel.getPreferredSize().getWidth() + 20, getHeight() + 95);
    setMinimumSize(getSize());
    setMaximumSize(new Dimension(getSize().width, getSize().height + 150));
    panel.setMaximumSize(new Dimension((int) getMaximumSize().getWidth(), 150));
    return panel;
}

From source file:de.atomfrede.tools.evalutation.ui.ExceptionDialog.java

@Override
public JComponent createContentPanel() {
    // TODO use here nicer layout, maybe with an icon

    JPanel panel = new JPanel(new BorderLayout(10, 10));
    panel.setBorder(BorderFactory.createEmptyBorder(20, 40, 40, 40));

    JLabel label = new JLabel("<html>An error occured!<br/>" + exception.toString() + "</html>");
    label.setHorizontalAlignment(SwingConstants.LEFT);
    panel.add(label, BorderLayout.CENTER);
    panel.add(new JLabel(Icons.IC_DIALOG_ERROR_LARGE), BorderLayout.WEST);
    setSize(panel.getPreferredSize());
    return panel;
}

From source file:de.juwimm.cms.content.panel.PanDocuments.java

private void setMaxButtonWidth(JPanel pan) {
    int currentWidth = pan.getPreferredSize().width;
    if (this.maxButtonWidth < currentWidth)
        this.maxButtonWidth = currentWidth;
}

From source file:davmail.ui.SettingsFrame.java

protected void updateMaximumSize(JPanel panel) {
    Dimension preferredSize = panel.getPreferredSize();
    preferredSize.width = Integer.MAX_VALUE;
    panel.setMaximumSize(preferredSize);
}

From source file:com.unionpay.upmp.jmeterplugin.gui.UPMPUrlConfigGui.java

/**
 * This method defines the Panel for the HTTP path, 'Follow Redirects'
 * 'Use KeepAlive', and 'Use multipart for HTTP POST' elements.
 *
 * @return JPanel The Panel for the path, 'Follow Redirects' and 'Use
 *         KeepAlive' elements./*  w w  w. j av a2  s  .c  o m*/
 */
protected Component getPathPanel() {
    path = new JTextField(15);

    JLabel label = new JLabel(JMeterUtils.getResString("path")); //$NON-NLS-1$
    label.setLabelFor(path);

    if (notConfigOnly) {
        followRedirects = new JCheckBox(JMeterUtils.getResString("follow_redirects")); // $NON-NLS-1$
        followRedirects.setSelected(true);
        followRedirects.addChangeListener(this);

        autoRedirects = new JCheckBox(JMeterUtils.getResString("follow_redirects_auto")); //$NON-NLS-1$
        autoRedirects.addChangeListener(this);
        autoRedirects.setSelected(false);// Default changed in 2.3 and again in 2.4

        useKeepAlive = new JCheckBox(JMeterUtils.getResString("use_keepalive")); // $NON-NLS-1$
        useKeepAlive.setSelected(true);

        useMultipartForPost = new JCheckBox(JMeterUtils.getResString("use_multipart_for_http_post")); // $NON-NLS-1$
        useMultipartForPost.setSelected(false);

        useBrowserCompatibleMultipartMode = new JCheckBox(
                JMeterUtils.getResString("use_multipart_mode_browser")); // $NON-NLS-1$
        useBrowserCompatibleMultipartMode
                .setSelected(UPMPSamplerBase.BROWSER_COMPATIBLE_MULTIPART_MODE_DEFAULT);

    }

    JPanel pathPanel = new JPanel(new BorderLayout(5, 0));
    pathPanel.add(label, BorderLayout.WEST);
    pathPanel.add(path, BorderLayout.CENTER);
    pathPanel.setMinimumSize(pathPanel.getPreferredSize());

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.add(pathPanel);
    if (notConfigOnly) {
        JPanel optionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        optionPanel.add(autoRedirects);
        optionPanel.add(followRedirects);
        optionPanel.add(useKeepAlive);
        optionPanel.add(useMultipartForPost);
        optionPanel.add(useBrowserCompatibleMultipartMode);
        optionPanel.setMinimumSize(optionPanel.getPreferredSize());
        panel.add(optionPanel);
    }

    return panel;
}

From source file:com.unionpay.upmp.jmeterplugin.gui.UPMPUrlConfigGui.java

protected JPanel getProtocolAndMethodPanel() {

    // Implementation

    if (showImplementation) {
        httpImplementation = new JLabeledChoice(UPMPConstant.upmp_implementation, // $NON-NLS-1$
                UPMPSamplerFactory.getImplementations());
        httpImplementation.addValue("");
    }//w w  w.  java  2s.c  om
    // PROTOCOL
    protocol = new JTextField(4);
    JLabel protocolLabel = new JLabel(JMeterUtils.getResString("protocol")); // $NON-NLS-1$
    protocolLabel.setLabelFor(protocol);

    // CONTENT_ENCODING
    contentEncoding = new JTextField(10);
    JLabel contentEncodingLabel = new JLabel(JMeterUtils.getResString("content_encoding")); // $NON-NLS-1$
    contentEncodingLabel.setLabelFor(contentEncoding);

    if (notConfigOnly) {
        method = new JLabeledChoice(JMeterUtils.getResString("method"), // $NON-NLS-1$
                UPMPSamplerBase.getValidMethodsAsArray());
    }

    JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));

    if (showImplementation) {
        panel.add(httpImplementation);
    }
    panel.add(protocolLabel);
    panel.add(protocol);
    panel.add(Box.createHorizontalStrut(5));

    if (notConfigOnly) {
        panel.add(method);
    }
    panel.setMinimumSize(panel.getPreferredSize());
    panel.add(Box.createHorizontalStrut(5));

    panel.add(contentEncodingLabel);
    panel.add(contentEncoding);
    panel.setMinimumSize(panel.getPreferredSize());
    return panel;
}

From source file:jchrest.gui.VisualSearchPane.java

private JPanel constructTrainingOptions() {
    _maxTrainingCycles = new JSpinner(new SpinnerNumberModel(5, 1, 1000, 1));
    _numFixations = new JSpinner(new SpinnerNumberModel(20, 1, 1000, 1));
    _maxNetworkSize = new JSpinner(new SpinnerNumberModel(100000, 1, 10000000, 1));

    JPanel panel = new JPanel();
    panel.setLayout(new SpringLayout());
    Utilities.addLabel(panel, "Domain of scenes:", _domainSelector);
    Utilities.addLabel(panel, "Number of scenes:", new JLabel("" + _scenes.size()));
    Utilities.addLabel(panel, "Maximum training cycles:", _maxTrainingCycles);
    Utilities.addLabel(panel, "Number of fixations per scene:", _numFixations);
    Utilities.addLabel(panel, "Maximum network size:", _maxNetworkSize);

    Utilities.makeCompactGrid(panel, 5, 2, 3, 3, 10, 5);
    panel.setMaximumSize(panel.getPreferredSize());

    JPanel ePanel = new JPanel();
    ePanel.setLayout(new GridLayout(1, 1));
    ePanel.add(panel);/* w  w w.ja v a2s  . c o  m*/

    return ePanel;
}

From source file:desmoj.extensions.visualization2d.engine.modelGrafic.StatisticGrafic.java

/**
 * Build a StatisticGrafic Instance/* w w  w  .j  a  v  a  2s.c  om*/
 * @param statistic         The associated statistic instance
 * @param viewId         Id of view
 * @param pointExtern      Middle point 
 * @param typeAnimation      Default animation type. This can changed by popup menu.
 *                      For animation types look at StatisticGrafic.ANIMATION_... 
 * @param isIntValue      In typeAnimation == StatisticGrafic.ANIMATION_LastValue
 *                      value is shown as integer.
 * @param deltaSize         The default size can be incremented/decremented 
 *                      by deltaSize. Null means no change. 
 * @param infopane         Grafic is used for infopane 
 * @throws ModelException
 */
public StatisticGrafic(Statistic statistic, String viewId, Point pointExtern, int typeAnimation,
        boolean isIntValue, Dimension deltaSize, boolean infopane) throws ModelException {

    this.statistic = statistic;
    if (viewId == null)
        viewId = "main";
    this.viewId = viewId;
    //System.out.println("StatisticGrafic-Konstructor   id: "+this.statistic.getId());
    this.pointExtern = pointExtern;
    this.transform();
    this.setCode();
    this.setBorder(BorderFactory.createTitledBorder(Grafic.Border_Default, this.code,
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, Grafic.FONT_DEFAULT,
            Grafic.COLOR_BORDER));
    this.deltaSize = deltaSize;
    if (this.deltaSize == null)
        this.deltaSize = new Dimension(0, 0);
    this.typeAnimation = typeAnimation;
    this.isIntValue = isIntValue;
    JPanel content = new JPanel();
    switch (this.typeAnimation) {
    case StatisticGrafic.ANIMATION_LastValue:
        content = this.buildLastValuePanel();
        break;
    case StatisticGrafic.ANIMATION_TimeValueDiagram:
        content = this.buildTimeValueDiagramPanel();
        break;
    case StatisticGrafic.ANIMATION_Histogram:
        if (statistic.hasHistogramSupport())
            content = this.buildHistogramPanel();
        else {
            this.typeAnimation = StatisticGrafic.ANIMATION_TimeValueDiagram;
            content = this.buildTimeValueDiagramPanel();
        }
        break;
    }
    this.setLayout(new GridLayout(1, 1));
    this.add(content);
    this.setOpaque(true);
    Dimension d = new Dimension(content.getPreferredSize().width + this.deltaSize.width,
            content.getPreferredSize().height + this.deltaSize.height);
    this.setBounds(this.pointIntern.x - d.width / 2, this.pointIntern.y - d.height / 2, d.width, d.height);
    this.update();
    // Listener hinzufuegen
    if (this.statistic.getModel().getCoordinatenListener() != null) {
        this.addMouseMotionListener(this.statistic.getModel().getCoordinatenListener());
        this.addMouseListener(this.statistic.getModel().getCoordinatenListener());
        if (!infopane && this.typeAnimation != StatisticGrafic.ANIMATION_LastValue) {
            content.addMouseMotionListener(this.statistic.getModel().getCoordinatenListener());
            content.addMouseListener(this.statistic.getModel().getCoordinatenListener());
        }
    }
    this.addMouseListener(this);
}

From source file:ffx.ui.ModelingPanel.java

private JPanel getAminoAcidPanel() {
    if (aminoPanel != null) {
        return aminoPanel;
    }/*  w w w. j a va2 s . co m*/
    JPanel buttonPanel = new JPanel(new GridLayout(4, 5, 2, 2));
    Residue.AA3 a[] = Residue.AA3.values();
    for (int i = 0; i < 20; i++) {
        JButton button = new JButton(a[i].name());
        button.setActionCommand("PROTEIN");
        button.addActionListener(this);
        buttonPanel.add(button);
    }
    buttonPanel.setMaximumSize(buttonPanel.getPreferredSize());
    aminoPanel = new JPanel();
    aminoPanel.setLayout(new BoxLayout(aminoPanel, BoxLayout.Y_AXIS));
    aminoPanel.add(buttonPanel);
    conformationComboBox = new JComboBox<>(Residue.Ramachandran);
    conformationComboBox.setFont(Font.decode("Monospaced"));
    conformationComboBox.setMaximumSize(buttonPanel.getPreferredSize());
    aminoPanel.add(conformationComboBox);
    return aminoPanel;
}