Example usage for javax.swing JPanel getMinimumSize

List of usage examples for javax.swing JPanel getMinimumSize

Introduction

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

Prototype

@Transient
public Dimension getMinimumSize() 

Source Link

Document

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

Usage

From source file:edu.ku.brc.specify.tasks.subpane.wb.DataImportDialog.java

/**
 * Creates the UI panel for a xls import
 * // w  ww .j  a v a 2s  .com
 * @return
 * JPanel
 */
private JPanel createConfigPanelForXLS() {
    //JPanel configPanel = new FormDebugPanel();
    JPanel configPanel = new JPanel();
    CellConstraints cc = new CellConstraints();
    PanelBuilder builder = new PanelBuilder(new FormLayout("5px, 15px, p, 30px, p:g, 15px", // columns               
            "5px," + //padding      
                    "p,3px, " + //file info separator
                    "p,3px, " + //file info lable
                    "p,10px, " + //row header
                    "p, 3px," + //previe separator
                    "f:p:g,5px," + //tablePreview
                    "30px,3px," + //data import status error panel
                    "p,10px" //buttongs
    ), configPanel);// rows

    JLabel fileInfo = createLabel(getResourceString("FILE_PREVIEW") + " " + fileName);
    JPanel buttonpanel = buildButtons();
    containsHeaders = createCheckBox(getResourceString("COLUMN_HEAD"));
    containsHeaders.setSelected(true);
    containsHeaders.addItemListener(new CheckboxItemListener());

    builder.addSeparator(getResourceString("FILE_IMPORT"), cc.xyw(2, 2, 4));
    builder.add(fileInfo, cc.xyw(3, 4, 4));
    builder.add(containsHeaders, cc.xyw(3, 6, 3));

    builder.addSeparator(getResourceString("DATA_PREVIEW"), cc.xyw(2, 8, 4));
    myDisplayTable = setXLSTableData(myDisplayTable);
    if (myDisplayTable == null) {
        return null;
    }
    builder.add(addtoScroll(myDisplayTable), cc.xyw(3, 10, 3));
    builder.add(errorPanel, cc.xyw(3, 12, 4));
    builder.add(buttonpanel, cc.xyw(2, 14, 4));
    configPanel.setMinimumSize(buttonpanel.getMinimumSize());
    return configPanel;
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.DataImportDialog.java

/**
 * Creates the UI panel for a csv import, displays config opionts.
 * //from   w  w w.jav a  2  s .  c  om
 * @return
 * JPanel - the panel to be displayed
 */
private JPanel createConfigPanelForCSV() {
    //JPanel configPanel = new FormDebugPanel();
    JPanel configPanel = new JPanel();
    CellConstraints cc = new CellConstraints();
    PanelBuilder builder = new PanelBuilder(new FormLayout("5px, 15px, p, 30px, p:g, 15px", // columns

            "5px," + //padding
                    "p,3px, " + //separator     
                    "p,10px, " + //delim panel        
                    "p,3px, " + //file info separator
                    "p,3px, " + //file info lable
                    "p,10px, " + //row header
                    "p, 3px," + //preview separator
                    "f:p:g,5px," + //tablePreview
                    "30px,3px," + //data import status error panel
                    "p,10px" //buttongs
    ), configPanel);// rows

    JLabel fileInfo = createLabel(getResourceString("FILE_PREVIEW") + " " + fileName);
    JPanel buttonpanel = buildButtons();
    containsHeaders = createCheckBox(getResourceString("COLUMN_HEAD"));
    containsHeaders.setSelected(true);
    containsHeaders.addItemListener(new CheckboxItemListener());

    builder.addSeparator(getResourceString("DATA_IMPORT_OPS"), cc.xyw(2, 2, 4));
    builder.add(createDelimiterPanel(), cc.xy(3, 4));
    builder.add(createOtherControlsForCSVPanel(), cc.xy(5, 4));

    builder.addSeparator(getResourceString("FILE_IMPORT"), cc.xyw(2, 6, 4));
    builder.add(fileInfo, cc.xyw(3, 8, 4));
    builder.add(containsHeaders, cc.xyw(3, 10, 3));

    builder.addSeparator(getResourceString("DATA_PREVIEW"), cc.xyw(2, 12, 4));

    myDisplayTable = setCSVTableData(myDisplayTable);
    builder.add(addtoScroll(myDisplayTable), cc.xyw(3, 14, 3));

    builder.add(errorPanel, cc.xyw(3, 16, 4));
    builder.add(buttonpanel, cc.xyw(2, 18, 4));
    configPanel.setMinimumSize(buttonpanel.getMinimumSize());
    return configPanel;
}

From source file:org.esa.beam.visat.toolviews.stat.StatisticsPanel.java

@Override
protected void initComponents() {
    init = true;/*from  ww w. jav  a 2s .  c  o m*/

    initHashMaps();

    statsSpreadsheet = null;

    statisticsCriteriaPanel = new StatisticsCriteriaPanel(getParentDialogContentPane());

    final JPanel rightPanel = getRightPanel();

    final ImageIcon collapseIcon = UIUtils.loadImageIcon("icons/PanelRight12.png");
    final ImageIcon collapseRolloverIcon = ToolButtonFactory.createRolloverIcon(collapseIcon);
    final ImageIcon expandIcon = UIUtils.loadImageIcon("icons/PanelLeft12.png");
    final ImageIcon expandRolloverIcon = ToolButtonFactory.createRolloverIcon(expandIcon);

    hideAndShowButton = ToolButtonFactory.createButton(collapseIcon, false);
    hideAndShowButton.setToolTipText("Collapse Options Panel");
    hideAndShowButton.setName("switchToChartButton");
    hideAndShowButton.addActionListener(new ActionListener() {

        public boolean rightPanelShown;

        @Override
        public void actionPerformed(ActionEvent e) {
            rightPanel.setVisible(rightPanelShown);
            if (rightPanelShown) {
                hideAndShowButton.setIcon(collapseIcon);
                hideAndShowButton.setRolloverIcon(collapseRolloverIcon);
                hideAndShowButton.setVisible(true);
                hideAndShowButton.setToolTipText("Collapse Options Panel");
            } else {
                hideAndShowButton.setIcon(expandIcon);
                hideAndShowButton.setRolloverIcon(expandRolloverIcon);
                hideAndShowButton.setVisible(true);
                hideAndShowButton.setToolTipText("Expand Options Panel");
            }
            rightPanelShown = !rightPanelShown;
        }
    });

    hideAndShowButton.setVisible(true);

    contentPanel = new JPanel(new GridLayout(-1, 1));
    contentPanel.setBackground(Color.WHITE);
    contentPanel.addMouseListener(popupHandler);

    contentScrollPane = new JScrollPane(contentPanel);
    contentScrollPane.setBorder(null);
    contentScrollPane.setBackground(Color.WHITE);

    spreadsheetPanel = new JPanel(new GridLayout(-1, 1));
    //    spreadsheetPanel.setBackground(Color.WHITE);
    spreadsheetPanel.addMouseListener(popupHandler);

    spreadsheetScrollPane = new JScrollPane(spreadsheetPanel);

    spreadsheetScrollPane.setBorder(null);
    //    spreadsheetScrollPane.setBackground(Color.WHITE);
    spreadsheetScrollPane.setMinimumSize(new Dimension(100, 100));
    spreadsheetScrollPane.setBorder(UIUtils.createGroupBorder("Statistics Spreadsheet"));
    spreadsheetScrollPane.setVisible(statisticsCriteriaPanel.showStatsSpreadSheet());

    leftPanel = new JPanel(new GridBagLayout());
    //        GridBagConstraints gbcLeftPanel = new GridBagConstraints();
    //        GridBagUtils.addToPanel(leftPanel, contentScrollPane, gbcLeftPanel, "fill=BOTH, weightx=1.0, weighty=1.0, anchor=NORTHWEST");
    //        GridBagUtils.addToPanel(leftPanel, spreadsheetScrollPane, gbcLeftPanel, "fill=BOTH, weightx=1.0, weighty=0.0, anchor=NORTHWEST, gridy=1,insets.top=5");

    initLeftPanel();

    backgroundPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    GridBagUtils.addToPanel(backgroundPanel, leftPanel, gbc,
            "fill=BOTH, weightx=1.0, weighty=1.0, anchor=NORTHWEST,insets.right=5");
    //   GridBagUtils.addToPanel(backgroundPanel, contentScrollPane, gbc, "fill=BOTH, weightx=1.0, weighty=1.0, anchor=NORTHWEST");
    //  GridBagUtils.addToPanel(backgroundPanel, spreadsheetScrollPane, gbc, "fill=BOTH, weightx=1.0, weighty=1.0, anchor=NORTHWEST, gridy=1");
    GridBagUtils.addToPanel(backgroundPanel, rightPanel, gbc,
            "gridx=1,gridy=0, fill=BOTH, weightx=0.0,anchor=NORTHEAST,insets.left=5");

    //   GridBagUtils.addToPanel(backgroundPanel, spreadsheetScrollPane, gbcLeftPanel, "fill=HORIZONTAL, weightx=1.0, weighty=1.0, anchor=NORTHWEST, gridy=1,gridx=0,gridwidth=2,insets.top=5");
    JLayeredPane layeredPane = new JLayeredPane();
    layeredPane.add(backgroundPanel, new Integer(0));
    layeredPane.add(hideAndShowButton, new Integer(1));
    add(layeredPane);

    int minWidth = leftPanel.getMinimumSize().width + rightPanel.getMinimumSize().width;
    int minHeight = Math.max(leftPanel.getMinimumSize().height, rightPanel.getMinimumSize().height);
    setMinimumSize(new Dimension(minWidth, minHeight));

}

From source file:shuffle.fwk.service.teams.EditTeamService.java

@SuppressWarnings("serial")
private Component makeTeamPanel() {

    JPanel firstOptionRow = new JPanel(new GridBagLayout());
    GridBagConstraints rowc = new GridBagConstraints();
    rowc.fill = GridBagConstraints.HORIZONTAL;
    rowc.weightx = 0.0;/* www  . ja v a2 s  . c om*/
    rowc.weighty = 0.0;

    rowc.weightx = 1.0;
    rowc.gridx = 1;
    stageChooser = new StageChooser(this);
    firstOptionRow.add(stageChooser, rowc);
    rowc.weightx = 0.0;

    JPanel secondOptionRow = new JPanel(new GridBagLayout());

    rowc.gridx = 1;
    JLabel megaLabel = new JLabel(getString(KEY_MEGA_LABEL));
    megaLabel.setToolTipText(getString(KEY_MEGA_TOOLTIP));
    secondOptionRow.add(megaLabel, rowc);

    rowc.gridx = 2;
    megaChooser = new JComboBox<String>();
    megaChooser.setToolTipText(getString(KEY_MEGA_TOOLTIP));
    secondOptionRow.add(megaChooser, rowc);

    rowc.gridx = 3;
    JPanel progressPanel = new JPanel(new BorderLayout());
    megaActive = new JCheckBox(getString(KEY_ACTIVE));
    megaActive.setSelected(false);
    megaActive.setToolTipText(getString(KEY_ACTIVE_TOOLTIP));
    progressPanel.add(megaActive, BorderLayout.WEST);
    megaProgressChooser = new JComboBox<Integer>();
    progressPanel.add(megaProgressChooser, BorderLayout.EAST);
    megaProgressChooser.setToolTipText(getString(KEY_MEGA_PROGRESS_TOOLTIP));
    secondOptionRow.add(progressPanel, rowc);

    JPanel thirdOptionRow = new JPanel(new GridBagLayout());

    rowc.gridx = 1;
    JButton clearTeamButton = new JButton(getString(KEY_CLEAR_TEAM));
    clearTeamButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            clearTeam();
        }
    });
    clearTeamButton.setToolTipText(getString(KEY_CLEAR_TEAM_TOOLTIP));
    thirdOptionRow.add(clearTeamButton, rowc);

    rowc.gridx = 2;
    woodCheckBox = new JCheckBox(getString(KEY_WOOD));
    woodCheckBox.setToolTipText(getString(KEY_WOOD_TOOLTIP));
    thirdOptionRow.add(woodCheckBox, rowc);

    rowc.gridx = 3;
    metalCheckBox = new JCheckBox(getString(KEY_METAL));
    metalCheckBox.setToolTipText(getString(KEY_METAL_TOOLTIP));
    thirdOptionRow.add(metalCheckBox, rowc);

    rowc.gridx = 4;
    coinCheckBox = new JCheckBox(getString(KEY_COIN));
    coinCheckBox.setToolTipText(getString(KEY_COIN_TOOLTIP));
    thirdOptionRow.add(coinCheckBox, rowc);

    rowc.gridx = 5;
    freezeCheckBox = new JCheckBox(getString(KEY_FREEZE));
    freezeCheckBox.setToolTipText(getString(KEY_FREEZE_TOOLTIP));
    thirdOptionRow.add(freezeCheckBox, rowc);

    JPanel topPart = new JPanel(new GridBagLayout());
    GridBagConstraints topC = new GridBagConstraints();
    topC.fill = GridBagConstraints.HORIZONTAL;
    topC.weightx = 0.0;
    topC.weighty = 0.0;
    topC.gridx = 1;
    topC.gridy = 1;
    topC.gridwidth = 1;
    topC.gridheight = 1;
    topC.anchor = GridBagConstraints.CENTER;

    topC.gridy = 1;
    topPart.add(firstOptionRow, topC);
    topC.gridy = 2;
    topPart.add(secondOptionRow, topC);
    topC.gridy = 3;
    topPart.add(thirdOptionRow, topC);

    addOptionListeners();

    teamPanel = new JPanel(new WrapLayout()) {
        // Fix to make it play nice with the scroll bar.
        @Override
        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            d.width = (int) (d.getWidth() - 20);
            return d;
        }
    };
    final JScrollPane scrollPane = new JScrollPane(teamPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER) {
        @Override
        public Dimension getMinimumSize() {
            Dimension d = super.getMinimumSize();
            d.width = topPart.getMinimumSize().width;
            d.height = rosterScrollPane.getPreferredSize().height - topPart.getPreferredSize().height;
            return d;
        }

        @Override
        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            d.width = topPart.getMinimumSize().width;
            d.height = rosterScrollPane.getPreferredSize().height - topPart.getPreferredSize().height;
            return d;
        }
    };
    scrollPane.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            scrollPane.revalidate();
        }
    });
    scrollPane.getVerticalScrollBar().setUnitIncrement(27);

    JPanel ret = new JPanel(new GridBagLayout());
    GridBagConstraints rc = new GridBagConstraints();
    rc.fill = GridBagConstraints.VERTICAL;
    rc.weightx = 0.0;
    rc.weighty = 0.0;
    rc.gridx = 1;
    rc.gridy = 1;
    rc.insets = new Insets(5, 5, 5, 5);
    ret.add(topPart, rc);
    rc.gridy += 1;
    rc.weightx = 0.0;
    rc.weighty = 1.0;
    rc.insets = new Insets(0, 0, 0, 0);
    ret.add(scrollPane, rc);
    return ret;
}