当前位置: 首页>>代码示例>>Java>>正文


Java JToggleButton类代码示例

本文整理汇总了Java中javax.swing.JToggleButton的典型用法代码示例。如果您正苦于以下问题:Java JToggleButton类的具体用法?Java JToggleButton怎么用?Java JToggleButton使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JToggleButton类属于javax.swing包,在下文中一共展示了JToggleButton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addButton

import javax.swing.JToggleButton; //导入依赖的package包/类
private JToggleButton addButton(final String value) {
    final int numBtns = m_buttons.size();

    if (numBtns >= (m_maxRows * m_panels.size())) {
        // create a new Panel
        final JPanel panel = new JPanel(new GridLayout(m_maxRows, 1));

        this.add(panel);

        m_panels.add(panel);
        m_lastPanel = panel;
    }
    // createButton and add this as itemListener
    final JToggleButton btn = new CustomToggleButton(value);
    btn.addActionListener(this);

    if (value.equals(ClassModel.NO_CLASS)) {
        btn.setText(m_defaultText);
    }

    m_lastPanel.add(btn); // add it to the last Panel

    m_buttons.add(btn);
    return btn;
}
 
开发者ID:knime,项目名称:knime-activelearning,代码行数:26,代码来源:ToggleButtonList.java

示例2: main

import javax.swing.JToggleButton; //导入依赖的package包/类
public static void main(String[] args) throws IntrospectionException {
    Class[] types = {
            Component.class,
            Container.class,
            JComponent.class,
            AbstractButton.class,
            JButton.class,
            JToggleButton.class,
    };
    // Control set. "enabled" and "name" has the same pattern and can be found
    String[] names = {
            "enabled",
            "name",
            "focusable",
    };
    for (String name : names) {
        for (Class type : types) {
            BeanUtils.getPropertyDescriptor(type, name);
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:Test4619792.java

示例3: setEnabled

import javax.swing.JToggleButton; //导入依赖的package包/类
/**
 * In addition to delegating the method to the label list and to
 * <tt>super</tt>, sets the background color to <tt>null</tt> when disabled
 * and back to the default when enabled.
 */
@Override
public void setEnabled(boolean enabled) {
    if (enabled != isEnabled()) {
        if (!enabled) {
            this.enabledBackground = getBackground();
            setBackground(null);
        } else if (this.enabledBackground != null) {
            setBackground(this.enabledBackground);
        }
        if (getLabelTree() != null) {
            getLabelTree().setEnabled(enabled);
        }
        for (JToggleButton button : getModeButtonMap().values()) {
            button.setEnabled(enabled);
        }
        getModeButton(getDefaultMode()).setSelected(true);
        // retrieve the layout action to get its key accelerator working
        getLayoutAction();
        super.setEnabled(enabled);
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:27,代码来源:JGraph.java

示例4: initSave

import javax.swing.JToggleButton; //导入依赖的package包/类
void initSave() {
	savePanel = new JPanel(new GridLayout(0,1));
	savePanel.setBorder( BorderFactory.createTitledBorder("Save Options"));
	ButtonGroup gp = new ButtonGroup();
	saveToFile = new JToggleButton("Save ASCII table");
	savePanel.add( saveToFile );
	gp.add( saveToFile );
	saveToClipboard = new JToggleButton("Copy to clipboard");
	savePanel.add( saveToClipboard );
	gp.add( saveToClipboard );
	saveJPEG = new JToggleButton("Save JPEG image");
	savePanel.add( saveJPEG );
	gp.add( saveJPEG );
	savePNG = new JToggleButton("Save PNG image");
	savePanel.add( savePNG );
	gp.add( savePNG );
	print = new JToggleButton("Print");
	savePanel.add( print );
	gp.add( print );
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:21,代码来源:GMAProfile.java

示例5: 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

示例6: toggleConsolePanel

import javax.swing.JToggleButton; //导入依赖的package包/类
public void toggleConsolePanel(Object source) {
    if (source instanceof JToggleButton) {
        final Boolean flag = ((JToggleButton) source).isSelected();
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                if (flag) {
                    executionAndConsoleSplitPane.setBottomComponent(consolePanel);
                    executionAndConsoleSplitPane.setDividerLocation(0.5);
                } else {
                    executionAndConsoleSplitPane.remove(consolePanel);
                }
            }
        });
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:17,代码来源:TestExecutionUI.java

示例7: 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

示例8: RuleEditorViews

import javax.swing.JToggleButton; //导入依赖的package包/类
public RuleEditorViews(RuleEditorPanel ruleEditorPanel) {
    this.ruleEditorPanel = ruleEditorPanel;

    updatedOnlyToggleButton = new JToggleButton(new ViewActionSupport.UpdatedOnlyViewAction(this));
    updatedOnlyToggleButton.setToolTipText(updatedOnlyToggleButton.getText());
    updatedOnlyToggleButton.setText(null);
    updatedOnlyToggleButton.setSelected(getViewMode() == ViewMode.UPDATED_ONLY);
    updatedOnlyToggleButton.setFocusable(false);

    categorizedToggleButton = new JToggleButton(new ViewActionSupport.CategorizedViewAction(this));
    categorizedToggleButton.setToolTipText(categorizedToggleButton.getText());
    categorizedToggleButton.setText(null);
    categorizedToggleButton.setSelected(getViewMode() == ViewMode.CATEGORIZED);
    categorizedToggleButton.setFocusable(false);

    allToggleButton = new JToggleButton(new ViewActionSupport.AllViewAction(this));
    allToggleButton.setToolTipText(allToggleButton.getText());
    allToggleButton.setText(null);
    allToggleButton.setSelected(getViewMode() == ViewMode.ALL);
    allToggleButton.setFocusable(false);

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:RuleEditorViews.java

示例9: init

import javax.swing.JToggleButton; //导入依赖的package包/类
private void init() {
    setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.X_AXIS));
    setFloatable(false);

    add(new javax.swing.Box.Filler(new java.awt.Dimension(10, 0),
            new java.awt.Dimension(10, 0),
            new java.awt.Dimension(10, 32767)));
    JLabel label = new JLabel("Properties");
    label.setFont(new Font("Default", Font.BOLD, 12));
    add(label);

    add(new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 32767)));

    add(Utils.createButton("Add Row", "add", "Ctrl+Plus", WebORTable.this));
    add(Utils.createButton("Delete Rows", "remove", "Ctrl+Minus", WebORTable.this));
    addSeparator();
    add(Utils.createButton("Move Rows Up", "up", "Ctrl+Up", WebORTable.this));
    add(Utils.createButton("Move Rows Down", "down", "Ctrl+Down", WebORTable.this));
    addSeparator();
    frameToggle = new JToggleButton(Utils.getIconByResourceName("/ui/resources/or/web/propViewer"));
    frameToggle.addItemListener(WebORTable.this);
    frameToggle.setToolTipText("Show/Hide Frame Property");
    frameToggle.setActionCommand("Toggle Frame");
    add(frameToggle);
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:26,代码来源:WebORTable.java

示例10: countSelectedButtons

import javax.swing.JToggleButton; //导入依赖的package包/类
/**
 * Count the selected and enabled buttons.
 *
 * @return
 */
public int countSelectedButtons()
{
    int count = 0;

    for (JToggleButton button : buttons)
    {
        if (button.isSelected() && button.isEnabled())
        {
            count++;
        }
    }

    return count;
}
 
开发者ID:nfriaa,项目名称:swing-memory-game,代码行数:20,代码来源:FrameGame.java

示例11: createTopPane

import javax.swing.JToggleButton; //导入依赖的package包/类
private JComponent createTopPane() {
    inputField = new JTextField(40);
    inputField.addActionListener( (e) -> sendMessage() );
    inputField.setMaximumSize( inputField.getPreferredSize() );
    
    JButton sendButton = new JButton( getLocalizedComponentText("sendButton") );
    sendButton.addActionListener( (e) -> sendMessage() );
    
    JPanel pane = new JPanel();
    pane.setLayout( new BoxLayout(pane, BoxLayout.LINE_AXIS) );
    
    crSwitch = new JToggleButton("CR", true);
    lfSwitch = new JToggleButton("LF", true);
    
    pane.add( inputField );
    pane.add( Box.createRigidArea( new Dimension(5, 0) ) );
    pane.add( sendButton );
    pane.add( Box.createGlue() );
    pane.add( crSwitch );
    pane.add( Box.createRigidArea( new Dimension(5, 0) ) );
    pane.add( lfSwitch );        
    
    pane.setBorder( BorderFactory.createEmptyBorder(3, 3, 3, 0) );
    
    return pane;
}
 
开发者ID:chipKIT32,项目名称:chipKIT-importer,代码行数:27,代码来源:SerialMonitorDisplayPane.java

示例12: getBuilder

import javax.swing.JToggleButton; //导入依赖的package包/类
static ComponentBuilder getBuilder(Instance instance, Heap heap) {
    if (DetailsUtils.isSubclassOf(instance, JButton.class.getName())) {
        return new JButtonBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JCheckBox.class.getName())) {
        return new JCheckBoxBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JRadioButton.class.getName())) {
        return new JRadioButtonBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JToggleButton.class.getName())) {
        return new JToggleButtonBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JCheckBoxMenuItem.class.getName())) {
        return new JCheckBoxMenuItemBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JRadioButtonMenuItem.class.getName())) {
        return new JRadioButtonMenuItemBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JMenu.class.getName())) {
        return new JMenuBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JMenuBar.class.getName())) {
        return new JMenuBarBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JMenuItem.class.getName())) {
        return new JMenuItemBuilder(instance, heap);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ButtonBuilders.java

示例13: getModeButtonMap

import javax.swing.JToggleButton; //导入依赖的package包/类
private Map<JGraphMode,JToggleButton> getModeButtonMap() {
    if (this.modeButtonMap == null) {
        this.modeButtonMap = new EnumMap<>(JGraphMode.class);
        ButtonGroup modeButtonGroup = new ButtonGroup();
        for (JGraphMode any : JGraphMode.values()) {
            JToggleButton button = new JToggleButton(getModeAction(any));
            Options.setLAF(button);
            button.setToolTipText(any.getName());
            button.setEnabled(isEnabled());
            this.modeButtonMap.put(any, button);
            modeButtonGroup.add(button);
        }
        this.modeButtonMap.get(EDIT_MODE).setSelected(true);
    }
    return this.modeButtonMap;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:17,代码来源:JGraph.java

示例14: createOpenViewButton

import javax.swing.JToggleButton; //导入依赖的package包/类
protected JToggleButton createOpenViewButton(ButtonGroup group,
                                             final SubView view) {
    JToggleButton button = new JToggleButton(view.getTitle());
    group.add(button);
    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            actionsRemoved(activeView.getActions());
            beforeSubviewActivated(view);
            content.removeAll();
            content.add(view, BorderLayout.CENTER);
            content.revalidate();
            content.repaint();
            activeView = view;
            actionsAdded(view.getActions());
        }
    });

    return button;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:22,代码来源:ReportEditorView.java

示例15: reset

import javax.swing.JToggleButton; //导入依赖的package包/类
public static void reset() {
    add(Component.class, JavaElement.class);
    add(JList.class, JListJavaElement.class);
    add(JTabbedPane.class, JTabbedPaneJavaElement.class);
    add(JComboBox.class, JComboBoxJavaElement.class);
    add(JTable.class, JTableJavaElement.class);
    add(JTableHeader.class, JTableHeaderJavaElement.class);
    add(JTree.class, JTreeJavaElement.class);
    add(JToggleButton.class, JToggleButtonJavaElement.class);
    add(JSpinner.class, JSpinnerJavaElement.class);
    add(JProgressBar.class, JProgressBarJavaElement.class);
    add(JSplitPane.class, JSplitPaneJavaElement.class);
    add(JTextComponent.class, JTextComponentJavaElement.class);
    add(EditorContainer.class, JTreeEditingContainerJavaElement.class);
    add(JEditorPane.class, JEditorPaneJavaElement.class);
    add(JMenuItem.class, JMenuItemJavaElement.class);
    add(JSlider.class, JSliderJavaElement.class);
    add(JSpinner.class, JSpinnerJavaElement.class);
    add(DefaultEditor.class, DefaultEditorJavaElement.class);
    add(JColorChooser.class, JColorChooserJavaElement.class);
    add(JFileChooser.class, JFileChooserJavaElement.class);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:23,代码来源:JavaElementFactory.java


注:本文中的javax.swing.JToggleButton类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。