Java Code Examples for javax.swing.AbstractButton#setMaximumSize()
The following examples show how to use
javax.swing.AbstractButton#setMaximumSize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ToolAdapterTabbedEditorDialog.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
@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; }
Example 2
Source File: CustomToolbar.java From netbeans with Apache License 2.0 | 5 votes |
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); }
Example 3
Source File: ToolButtonFactory.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
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); }
Example 4
Source File: AbstractSearchResultsPanel.java From netbeans with Apache License 2.0 | 4 votes |
protected void sizeButton(AbstractButton button) { Dimension dim = new Dimension(24, 24); button.setMinimumSize(dim); button.setMaximumSize(dim); button.setPreferredSize(dim); }
Example 5
Source File: ToolAdapterEditorDialog.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
@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; }
Example 6
Source File: ToolAdapterTabbedEditorDialog.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
@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; }