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


Java JToggleButton.setBorder方法代碼示例

本文整理匯總了Java中javax.swing.JToggleButton.setBorder方法的典型用法代碼示例。如果您正苦於以下問題:Java JToggleButton.setBorder方法的具體用法?Java JToggleButton.setBorder怎麽用?Java JToggleButton.setBorder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JToggleButton的用法示例。


在下文中一共展示了JToggleButton.setBorder方法的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: preencher

import javax.swing.JToggleButton; //導入方法依賴的package包/類
/**
 * Preencher a janela para escolher o verso do card
 *
 * @param selected verso pré-selecionado. -1 para nenhum verso
 * pré-selecionado.
 */
private void preencher(int selected) {
    for (int i = 0; i < CARDBACK.size(); i++) {
        ImageIcon cardBack = Img.recortar(CARDBACK.get(i).getCardBackImage(), 20, 45, 164, 240);
        cardBack = Img.redimensionaImg(cardBack.getImage(), 0.55);
        JToggleButton button = new JToggleButton(cardBack);
        button.addActionListener(getAction(i));
        button.setBorder(null);
        button.setBackground(new Color(0, 0, 0, 0));
        button.setOpaque(false);
        button.setFocusPainted(false);
        buttonGroup.add(button);
        if (i == selected) {
            button.setBorder(new LineBorder(Color.RED, 2));
            button.setSelected(true);
        }
        jPanelCards.add(button);
    }
}
 
開發者ID:limagiran,項目名稱:hearthstone,代碼行數:25,代碼來源:EscolherCardBack.java

示例5: initToggle

import javax.swing.JToggleButton; //導入方法依賴的package包/類
void initToggle() {
	shapeToggle = new JToggleButton(Icons.getIcon(Icons.POLYGON, false));
	shapeToggle.setSelectedIcon(Icons.getIcon(Icons.POLYGON, true));
	shapeToggle.setBorder( null );
	shapeToggle.setToolTipText("Shapefile Manager");
	shapeToggle.addActionListener( new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			if( shapeToggle.isSelected() ) {
			//	if( suite.getShapes().size()==0 ) {
				if( table==null ) {
					init();
				//	shapeToggle.setSelected(false);
					return;
				}
			}
			dialog.setVisible( shapeToggle.isSelected() );
		}
	});
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:20,代碼來源:ViewShapes.java

示例6: createLassoPanel

import javax.swing.JToggleButton; //導入方法依賴的package包/類
protected JPanel createLassoPanel() {
		JPanel p2 = new JPanel(new BorderLayout());
		JToggleButton tb = new JToggleButton(Icons.getIcon(Icons.LASSO, false));
		tb.setSelectedIcon(Icons.getIcon(Icons.LASSO, true));
		tb.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
//				((AbstractButton)e.getSource()).setSelected(true);
				if (((AbstractButton)e.getSource()).isSelected()) {
					map.setBaseCursor(Cursors.getCursor(Cursors.LASSO));
				} else
					map.setBaseCursor(Cursor.getDefaultCursor());
			}
		});
		tb.setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 0));
		p2.add(tb, BorderLayout.WEST);
		p2.setBorder(null);
		JLabel l = new JLabel("<html>Lasso<br>Data</html>");
		l.setSize(35, 60);
		l.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0));
		p2.add(l);

//		***** GMA 1.6.2: Listen for lasso button to ensure that it works correctly with the 
//		zoom buttons in the main toolbar
		lassoTB = tb;
		lassoTB.addMouseListener(this);

		return p2;
	}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:29,代碼來源:CustomDB.java

示例7: stylizeToggleButton

import javax.swing.JToggleButton; //導入方法依賴的package包/類
/**
 * Created by Kevin Le to stylize buttons to all look the same
 * Edited by me to allow for toggle buttons to be stylized
 * @param b
 */
public void stylizeToggleButton(JToggleButton b){
	Border thickBorder = new LineBorder(Color.WHITE, 3);
   	b.setBorder(thickBorder);
	b.setContentAreaFilled(false);
	b.setOpaque(true);
	b.setBackground(Color.BLACK);
	b.setForeground(Color.WHITE);
}
 
開發者ID:kevingilboy,項目名稱:COE1186,代碼行數:14,代碼來源:TrainModelNewGUI.java

示例8: updateToolbar

import javax.swing.JToggleButton; //導入方法依賴的package包/類
private void updateToolbar(FileObject file, Collection<CssStylesPanelProvider> activeProviders) {

        toolBar.removeAll();
        if (activeProviders.size() <= 1) {
            //remove the whole toolbar, if there's one or zero providers
            removeToolbar();
        } else {
            addToolbar();
        }

        // Button group for document and source buttons
        ButtonGroup buttonGroup = new ButtonGroup();

        boolean first = true;

        CssStylesPanelProvider selected = (file == null) ? null : selectedTabs.get(file.getMIMEType());

        //do the active providers contain the pre-selected provider for this mimetype?
        boolean containsPreselected = selected == null ? false : activeProviders.contains(selected);

        for (CssStylesPanelProvider provider : activeProviders) {
            JToggleButton button = new JToggleButton();
            button.setText(provider.getPanelDisplayName());
            button.setActionCommand(provider.getPanelID());
            button.addActionListener(toolbarListener);

            button.setFocusable(true);
            button.setFocusPainted(false);
            button.setRolloverEnabled(true);

            //copied from org.netbeans.core.multiview.TabsComponent.createButton to make the look 
            //similar to the editor tabs
            Border b = (getButtonBorder());
            if (b != null) {
                button.setBorder(b);
            }
            if (AQUA) {
                button.putClientProperty("JButton.buttonType", "square"); //NOI18N
                button.putClientProperty("JComponent.sizeVariant", "small"); //NOI18N
            }

            buttonGroup.add(button);
            toolBar.add(button);

            if (containsPreselected) {
                //one of the active providers is already pre-selected by user
                if (provider == selected) {
                    //the selected one - activate it
                    button.setSelected(true);
                    setActiveProvider(provider);
                } else {
                    button.setSelected(false);
                }
            } else {
                //no provider has been explicitly selected by the user yet
                button.setSelected(first);
                if (first) {
                    setActiveProvider(provider);
                    first = false;
                }
            }
        }

        revalidate();
        repaint();
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:67,代碼來源:CssStylesPanel.java


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