本文整理汇总了Java中javax.swing.JToggleButton.setMargin方法的典型用法代码示例。如果您正苦于以下问题:Java JToggleButton.setMargin方法的具体用法?Java JToggleButton.setMargin怎么用?Java JToggleButton.setMargin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JToggleButton
的用法示例。
在下文中一共展示了JToggleButton.setMargin方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: createToggle
import javax.swing.JToggleButton; //导入方法依赖的package包/类
private JToggleButton createToggle (FiltersDescriptor filtersDesc, int index) {
boolean isSelected = filtersDesc.isSelected(index);
Icon icon = filtersDesc.getSelectedIcon(index);
// ensure small size, just for the icon
JToggleButton toggleButton = new JToggleButton(icon, isSelected);
// Dimension size = new Dimension(icon.getIconWidth(), icon.getIconHeight());
// toggleButton.setPreferredSize(size);
toggleButton.setMargin(new Insets(2, 2, 2, 2));
toggleButton.setToolTipText(filtersDesc.getTooltip(index));
toggleButton.setFocusable(false);
filtersDesc.connectToggleButton(index, toggleButton);
return toggleButton;
}
示例7: 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;
}
示例8: buildGui
import javax.swing.JToggleButton; //导入方法依赖的package包/类
/**
* (Re)constructs the UI. This can be called many times, whenever a
* significant value (such as {@link #maximumFastChoices}, or the model)
* has changed.
*/
private void buildGui(){
removeAll();
if(model != null && model.getSize() > 0){
if(model.getSize() > maximumFastChoices){
//use combobox
add(combo);
}else{
//use buttons
//first clear the old buttons, if any exist
if(buttonToValueMap.size() > 0){
for(AbstractButton aBtn : buttonToValueMap.keySet()){
aBtn.removeItemListener(sharedItemListener);
}
}
//now create the new buttons
buttonToValueMap.clear();
for(int i = 0; i < model.getSize(); i++){
Object aValue = model.getElementAt(i);
JToggleButton aButton = new JToggleButton(aValue.toString());
if(defaultButtonMargin != null) aButton.setMargin(defaultButtonMargin);
aButton.addItemListener(sharedItemListener);
buttonToValueMap.put(aButton, aValue);
add(aButton);
}
}
}
revalidate();
}