本文整理匯總了Java中javax.swing.JToggleButton.setPreferredSize方法的典型用法代碼示例。如果您正苦於以下問題:Java JToggleButton.setPreferredSize方法的具體用法?Java JToggleButton.setPreferredSize怎麽用?Java JToggleButton.setPreferredSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JToggleButton
的用法示例。
在下文中一共展示了JToggleButton.setPreferredSize方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createToggleButton
import javax.swing.JToggleButton; //導入方法依賴的package包/類
private static JToggleButton createToggleButton (final String id, String iconPath, String tooltip) {
Icon icon = ImageUtilities.loadImageIcon(iconPath, false);
boolean isSelected = isButtonSelected(id);
final JToggleButton toggleButton = new JToggleButton(icon, isSelected);
// ensure small size, just for the icon
Dimension size = new Dimension(icon.getIconWidth() + 8, icon.getIconHeight() + 8);
toggleButton.setPreferredSize(size);
toggleButton.setMargin(new Insets(1, 1, 1, 1));
if (!"Aqua".equals(UIManager.getLookAndFeel().getID())) { //NOI18N
// We do not want an ugly border with the exception of Mac, where it paints the toggle state!
toggleButton.setBorder(new EmptyBorder(toggleButton.getBorder().getBorderInsets(toggleButton)));
}
toggleButton.setToolTipText(tooltip);
toggleButton.setFocusable(false);
return toggleButton;
}
示例2: 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;
}
示例3: createToggleButton
import javax.swing.JToggleButton; //導入方法依賴的package包/類
private static JToggleButton createToggleButton (final String id, String iconName, String tooltip) {
Icon icon = loadIcon(iconName);
boolean isSelected = isButtonSelected(id);
final JToggleButton toggleButton = new JToggleButton(icon, isSelected);
// ensure small size, just for the icon
Dimension size = new Dimension(icon.getIconWidth() + 8, icon.getIconHeight() + 8);
toggleButton.setPreferredSize(size);
toggleButton.setMargin(new Insets(1, 1, 1, 1));
if (!"Aqua".equals(UIManager.getLookAndFeel().getID())) { //NOI18N
// We do not want an ugly border with the exception of Mac, where it paints the toggle state!
toggleButton.setBorder(new EmptyBorder(toggleButton.getBorder().getBorderInsets(toggleButton)));
}
toggleButton.setToolTipText(tooltip);
toggleButton.setFocusable(false);
return toggleButton;
}
示例4: createActivateBreakpointsActionButton
import javax.swing.JToggleButton; //導入方法依賴的package包/類
@NbBundle.Messages({"CTL_DeactivateAllBreakpoints=Deactivate all breakpoints in current session",
"CTL_ActivateAllBreakpoints=Activate all breakpoints in current session",
"CTL_NoDeactivation=The current session does not allow to deactivate breakpoints",
"CTL_NoSession=No debugger session"})
public static AbstractButton createActivateBreakpointsActionButton() {
ImageIcon icon = ImageUtilities.loadImageIcon(DEACTIVATED_LINE_BREAKPOINT, false);
final JToggleButton button = new JToggleButton(icon);
// ensure small size, just for the icon
Dimension size = new Dimension(icon.getIconWidth() + 8, icon.getIconHeight() + 8);
button.setPreferredSize(size);
button.setMargin(new Insets(1, 1, 1, 1));
button.setBorder(new EmptyBorder(button.getBorder().getBorderInsets(button)));
button.setToolTipText(Bundle.CTL_DeactivateAllBreakpoints());
button.setFocusable(false);
final BreakpointsActivator ba = new BreakpointsActivator(button);
button.addActionListener(ba);
DebuggerManager.getDebuggerManager().addDebuggerListener(DebuggerManager.PROP_CURRENT_ENGINE, new DebuggerManagerAdapter() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
DebuggerEngine de = (DebuggerEngine) evt.getNewValue();
ba.setCurrentEngine(de);
}
});
ba.setCurrentEngine(DebuggerManager.getDebuggerManager().getCurrentEngine());
return button;
}
示例5: 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);
}
}
示例6: createToggle
import javax.swing.JToggleButton; //導入方法依賴的package包/類
private JToggleButton createToggle (Map<String,Boolean> fStates, int index) {
boolean isSelected = filtersDesc.isSelected(index);
Icon icon = filtersDesc.getSelectedIcon(index);
// ensure small size, just for the icon
JToggleButton result = new JToggleButton(icon, isSelected);
Dimension size = new Dimension(icon.getIconWidth() + 6, icon.getIconHeight() + 4);
result.setPreferredSize(size);
result.setMargin(new Insets(2,3,2,3));
result.setToolTipText(filtersDesc.getTooltip(index));
fStates.put(filtersDesc.getName(index), Boolean.valueOf(isSelected));
return result;
}
示例7: createToggle
import javax.swing.JToggleButton; //導入方法依賴的package包/類
private JToggleButton createToggle (Map<String,Boolean> fStates, int index) {
boolean isSelected = getPreferences().getBoolean( filtersDesc.getName(index), filtersDesc.isSelected(index) );
Icon icon = filtersDesc.getSelectedIcon(index);
// ensure small size, just for the icon
JToggleButton result = new JToggleButton(icon, isSelected);
Dimension size = new Dimension(icon.getIconWidth() + 6, icon.getIconHeight() + 4);
result.setPreferredSize(size);
result.setMargin(new Insets(2,3,2,3));
result.setToolTipText(filtersDesc.getTooltip(index));
result.setFocusable(false);
fStates.put(filtersDesc.getName(index), Boolean.valueOf(isSelected));
return result;
}
示例8: createToggle
import javax.swing.JToggleButton; //導入方法依賴的package包/類
private JToggleButton createToggle (Map fStates, int index) {
boolean isSelected = filtersDesc.isSelected(index);
Icon icon = filtersDesc.getSelectedIcon(index);
// ensure small size, just for the icon
JToggleButton result = new JToggleButton(icon, isSelected);
Dimension size = new Dimension(icon.getIconWidth() + 6, icon.getIconHeight() + 4);
result.setPreferredSize(size);
result.setMargin(new Insets(2,3,2,3));
result.setToolTipText(filtersDesc.getTooltip(index));
fStates.put(filtersDesc.getName(index), Boolean.valueOf(isSelected));
return result;
}
示例9: 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);
}
}
示例10: arrume
import javax.swing.JToggleButton; //導入方法依賴的package包/類
private JToggleButton arrume(JToggleButton btn) {
Dimension btnDim = new Dimension(40, 40);
btn.setHideActionText(true);
btn.setFocusable(false);
btn.setPreferredSize(btnDim);
btn.setDoubleBuffered(true);
//btn.setMargin(new Insets(2, 5, 2, 5));
btn.setRolloverEnabled(false);
return btn;
}