當前位置: 首頁>>代碼示例>>Java>>正文


Java JToggleButton.setMargin方法代碼示例

本文整理匯總了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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:VariablesViewButtons.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:VariablesViewButtons.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:BreakpointsViewButtons.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:FiltersManager.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:FiltersManager.java

示例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;
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:InfoPanel.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:FiltersManager.java

示例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();
}
 
開發者ID:GateNLP,項目名稱:gate-core,代碼行數:34,代碼來源:JChoice.java


注:本文中的javax.swing.JToggleButton.setMargin方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。