本文整理汇总了Java中javax.swing.JToggleButton.setMinimumSize方法的典型用法代码示例。如果您正苦于以下问题:Java JToggleButton.setMinimumSize方法的具体用法?Java JToggleButton.setMinimumSize怎么用?Java JToggleButton.setMinimumSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JToggleButton
的用法示例。
在下文中一共展示了JToggleButton.setMinimumSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createToggle
import javax.swing.JToggleButton; //导入方法依赖的package包/类
private JToggleButton createToggle(Map<String, Boolean> fStates, int index) {
boolean isSelected = filtersDesc.isSelected(index);
boolean enabled = filtersDesc.isEnabled(index);
Icon icon = filtersDesc.getIcon(index);
// ensure small size, just for the icon
JToggleButton result = new JToggleButton(icon, enabled && isSelected);
Dimension size = new Dimension(21, 21); // 3 less than other buttons
result.setMaximumSize(size);
result.setMinimumSize(size);
result.setPreferredSize(size);
if ("Aqua".equals(UIManager.getLookAndFeel().getID())) { //NOI18N
result.setBorderPainted(true);
} else {
result.setBorderPainted(false);
}
// result.setMargin(new Insets(2, 3, 2, 3));
result.setToolTipText(filtersDesc.getTooltip(index));
result.setEnabled(enabled);
fStates.put(filtersDesc.getKey(index), Boolean.valueOf(isSelected));
return result;
}
示例2: addAdditionalButtons
import javax.swing.JToggleButton; //导入方法依赖的package包/类
private void addAdditionalButtons(JToggleButton[] sortButtons) {
Dimension space = new Dimension(3, 0);
for (JToggleButton button : sortButtons) {
Dimension size = new Dimension(21, 21); // 3 less than other buttons
button.setMaximumSize(size);
button.setMinimumSize(size);
button.setPreferredSize(size);
// button.setMargin(new Insets(2, 3, 2, 3));
toolbar.addSeparator(space);
toolbar.add(button);
}
}
示例3: ToggleButtonGroup
import javax.swing.JToggleButton; //导入方法依赖的package包/类
/**
* Creates a new button group from the given Actions (requires at least two actions).
*
* @param preferredSize
* the preferredSize of the nested {@link CompositeToggleButton}s or {@code null}
* @param actions
* the action
*/
public ToggleButtonGroup(Dimension preferredSize, Action... actions) {
if (actions.length < 2) {
throw new IllegalArgumentException("At least two primary actions must be specified.");
}
this.setOpaque(false);
this.preferredSize = preferredSize;
primaryButtons = new CompositeToggleButton[actions.length];
for (int i = 0; i < actions.length; i++) {
int position;
if (i == 0) {
position = SwingConstants.LEFT;
} else if (i < actions.length - 1) {
position = SwingConstants.CENTER;
} else {
position = SwingConstants.RIGHT;
}
primaryButtons[i] = new CompositeToggleButton(actions[i], position);
}
// align buttons left to right with no padding
GridBagLayout layout = new GridBagLayout();
setLayout(layout);
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = new Insets(0, 0, 0, 0);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weighty = 1;
for (JToggleButton button : primaryButtons) {
button.addActionListener(buttonChooser);
if (preferredSize != null) {
button.setMinimumSize(preferredSize);
button.setPreferredSize(preferredSize);
}
add(button, gbc);
}
}
示例4: waypointAdded
import javax.swing.JToggleButton; //导入方法依赖的package包/类
/**
* Called when a waypoint is added. This implementation adds a waypoint button.
* @param graphic the waypoint graphic, whose ID may or may not be populated.
* @param graphicUid the waypoint graphic's ID.
* @see RouteListener#waypointAdded(com.esri.core.map.Graphic, int)
*/
public void waypointAdded(Graphic graphic, int graphicUid) {
final JToggleButton button = new JToggleButton((String) graphic.getAttributeValue("name"));
waypointButtonToGraphicId.put(button, graphicUid);
graphicIdToWaypointButton.put(graphicUid, button);
Font font = new Font("Arial", Font.PLAIN, 18);
button.setFont(font);
button.setFocusable(false);
button.setSelected(false);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (button == selectedWaypointButton) {
//Unselect
buttonGroup_waypoints.remove(button);
button.setSelected(false);
buttonGroup_waypoints.add(button);
selectedWaypointButton = null;
routeController.setSelectedWaypoint(null);
} else {
selectedWaypointButton = button;
routeController.setSelectedWaypoint(waypointButtonToGraphicId.get(button));
}
}
});
button.setMaximumSize(new Dimension(Integer.MAX_VALUE, 60));
button.setMinimumSize(new Dimension(0, 60));
jPanel_waypointsList.add(button);
buttonGroup_waypoints.add(button);
}