javax.swing.AbstractButton#setMaximumSize ( )源码实例Demo

下面列出了javax.swing.AbstractButton#setMaximumSize ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Override
protected JPanel createParametersPanel() {
    JPanel paramsPanel = new JPanel();
    BoxLayout layout = new BoxLayout(paramsPanel, BoxLayout.PAGE_AXIS);
    paramsPanel.setLayout(layout);
    AbstractButton addParamBut = ToolButtonFactory.createButton(UIUtils.loadImageIcon(Bundle.Icon_Add()), false);
    addParamBut.setText("New Parameter");
    addParamBut.setMaximumSize(new Dimension(150, controlHeight));
    addParamBut.setAlignmentX(Component.LEFT_ALIGNMENT);
    addParamBut.setAlignmentY(Component.TOP_ALIGNMENT);
    paramsPanel.add(addParamBut);
    JScrollPane tableScrollPane = new JScrollPane(paramsTable);
    tableScrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
    paramsPanel.add(tableScrollPane);
    addParamBut.addActionListener(e -> paramsTable.addParameterToTable());
    return paramsPanel;
}
 
源代码2 项目: netbeans   文件: CustomToolbar.java
public void addButton(AbstractButton button) {
    Icon icon = button.getIcon();
    Dimension size = new Dimension(icon.getIconWidth() + 6, icon.getIconHeight() + 10);
    button.setMinimumSize(size);
    button.setPreferredSize(size);
    button.setMaximumSize(size);
    button.setMargin(new Insets(5, 4, 5, 4));
    toolbar.add(button);
}
 
源代码3 项目: snap-desktop   文件: ToolButtonFactory.java
private static void configure(AbstractButton button) {

        RolloverButtonEventListener l = new RolloverButtonEventListener();
        button.addMouseListener(l);
        button.addItemListener(l);

        if (button.getAction() != null) {
            if (button.getIcon() != null) {
                button.putClientProperty("hideActionText", Boolean.TRUE);
            }
            Object largeIcon = button.getAction().getValue("_largeIcon");
            if (largeIcon instanceof Icon) {
                button.setIcon((Icon) largeIcon);
            }
        }

        Icon icon = button.getIcon();
        int minWidth = BUTTON_MIN_SIZE;
        int minHeight = BUTTON_MIN_SIZE;
        if (icon != null) {
            button.setText(null);
            minWidth = Math.max(icon.getIconWidth(), BUTTON_MIN_SIZE);
            minHeight = Math.max(icon.getIconHeight(), BUTTON_MIN_SIZE);
            if (icon instanceof ImageIcon) {
                button.setRolloverIcon(createRolloverIcon((ImageIcon) icon));
            }
        } else {
            button.setText("[?]");
        }
        final int space = 3;
        Dimension prefSize = new Dimension(minWidth + space, minHeight + space);
        Dimension minSize = new Dimension(minWidth, minHeight);
        Dimension maxSize = new Dimension(minWidth + space, minHeight + space);
        button.setPreferredSize(prefSize);
        button.setMaximumSize(maxSize);
        button.setMinimumSize(minSize);

    }
 
源代码4 项目: netbeans   文件: AbstractSearchResultsPanel.java
protected void sizeButton(AbstractButton button) {
    Dimension dim = new Dimension(24, 24);
    button.setMinimumSize(dim);
    button.setMaximumSize(dim);
    button.setPreferredSize(dim);
}
 
源代码5 项目: snap-desktop   文件: ToolAdapterEditorDialog.java
@Override
protected JPanel createVariablesPanel() {
    JPanel variablesBorderPanel = new JPanel();
    BoxLayout layout = new BoxLayout(variablesBorderPanel, BoxLayout.PAGE_AXIS);
    variablesBorderPanel.setLayout(layout);
    variablesBorderPanel.setBorder(BorderFactory.createTitledBorder(Bundle.CTL_Panel_SysVar_Border_TitleText()));

    AbstractButton addVariableButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon(Bundle.Icon_Add()), false);
    addVariableButton.setText(Bundle.CTL_Button_Add_Variable_Text());
    addVariableButton.setAlignmentX(Component.LEFT_ALIGNMENT);
    addVariableButton.setMaximumSize(new Dimension(150, controlHeight));

    AbstractButton addDependentVariableButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon(Bundle.Icon_Add()), false);
    addDependentVariableButton.setText(Bundle.CTL_Button_Add_PDVariable_Text());
    addDependentVariableButton.setAlignmentX(Component.LEFT_ALIGNMENT);
    addDependentVariableButton.setMaximumSize(new Dimension(250, controlHeight));

    JPanel buttonsPannel = new JPanel(new SpringLayout());
    buttonsPannel.add(addVariableButton);
    buttonsPannel.add(addDependentVariableButton);
    SpringUtilities.makeCompactGrid(buttonsPannel, 1, 2, 0, 0, 0, 0);
    buttonsPannel.setAlignmentX(Component.LEFT_ALIGNMENT);
    variablesBorderPanel.add(buttonsPannel);

    varTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    varTable.setRowHeight(20);
    JScrollPane scrollPane = new JScrollPane(varTable);
    scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
    variablesBorderPanel.add(scrollPane);
    variablesBorderPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    Dimension variablesPanelDimension = new Dimension((formWidth - 3 * DEFAULT_PADDING) / 2 - 2 * DEFAULT_PADDING, 130);
    variablesBorderPanel.setMinimumSize(variablesPanelDimension);
    variablesBorderPanel.setMaximumSize(variablesPanelDimension);
    variablesBorderPanel.setPreferredSize(variablesPanelDimension);

    addVariableButton.addActionListener(e -> {
        newOperatorDescriptor.getVariables().add(new SystemVariable("key", ""));
        varTable.revalidate();
    });

    addDependentVariableButton.addActionListener(e -> {
        newOperatorDescriptor.getVariables().add(new SystemDependentVariable("key", ""));
        varTable.revalidate();
    });

    return variablesBorderPanel;
}
 
@Override
protected JPanel createVariablesPanel() {
    JPanel variablesBorderPanel = new JPanel();
    BoxLayout layout = new BoxLayout(variablesBorderPanel, BoxLayout.PAGE_AXIS);
    variablesBorderPanel.setLayout(layout);

    AbstractButton addVariableButton =
            ToolButtonFactory.createButton(UIUtils.loadImageIcon(Bundle.Icon_Add()), false);
    addVariableButton.setText(Bundle.CTL_Button_Add_Variable_Text());
    addVariableButton.setMaximumSize(new Dimension(150, controlHeight));
    addVariableButton.setAlignmentX(Component.LEFT_ALIGNMENT);

    AbstractButton addDependentVariableButton =
            ToolButtonFactory.createButton(UIUtils.loadImageIcon(Bundle.Icon_Add()), false);
    addDependentVariableButton.setText(Bundle.CTL_Button_Add_PDVariable_Text());
    addDependentVariableButton.setMaximumSize(new Dimension(250, controlHeight));
    addDependentVariableButton.setAlignmentX(Component.LEFT_ALIGNMENT);

    JPanel buttonsPannel = new JPanel(new SpringLayout());
    buttonsPannel.add(addVariableButton);
    buttonsPannel.add(addDependentVariableButton);
    SpringUtilities.makeCompactGrid(buttonsPannel, 1, 2, 0, 0, 0, 0);
    buttonsPannel.setAlignmentX(Component.LEFT_ALIGNMENT);
    variablesBorderPanel.add(buttonsPannel);

    varTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    varTable.setRowHeight(controlHeight);
    int widths[] = {controlHeight, 3 * controlHeight, 10 * controlHeight};
    for (int i = 0; i < widths.length; i++) {
        TableColumn column = varTable.getColumnModel().getColumn(i);
        column.setPreferredWidth(widths[i]);
        column.setWidth(widths[i]);

    }
    JScrollPane scrollPane = new JScrollPane(varTable);
    scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
    variablesBorderPanel.add(scrollPane);
    variablesBorderPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    Dimension variablesPanelDimension =
            new Dimension((formWidth - 3 * DEFAULT_PADDING) / 2 - 2 * DEFAULT_PADDING, 130);
    variablesBorderPanel.setMinimumSize(variablesPanelDimension);
    variablesBorderPanel.setMaximumSize(variablesPanelDimension);
    variablesBorderPanel.setPreferredSize(variablesPanelDimension);

    addVariableButton.addActionListener(e -> {
        newOperatorDescriptor.getVariables().add(new SystemVariable("key", ""));
        varTable.revalidate();
    });

    addDependentVariableButton.addActionListener(e -> {
        newOperatorDescriptor.getVariables().add(new SystemDependentVariable("key", ""));
        varTable.revalidate();
    });

    return variablesBorderPanel;
}