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


Java ToggleButtonModel类代码示例

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


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

示例1: initRadioButtons

import javax.swing.JToggleButton.ToggleButtonModel; //导入依赖的package包/类
private void initRadioButtons() {
    
    applicationDescButtonModel = new ToggleButtonModel();
    appletDescButtonModel = new ToggleButtonModel();
    compDescButtonModel = new ToggleButtonModel();
    bg = new ButtonGroup();
    applicationDescButtonModel.setGroup(bg);
    appletDescButtonModel.setGroup(bg);
    compDescButtonModel.setGroup(bg);
    
    String desc = evaluator.getProperty(JNLP_DESCRIPTOR);
    if (desc != null) {
        if (desc.equals(DescType.application.toString())) {
            applicationDescButtonModel.setSelected(true);
        } else if (desc.equals(DescType.applet.toString())) {
            appletDescButtonModel.setSelected(true);
        } else if (desc.equals(DescType.component.toString())) {
            compDescButtonModel.setSelected(true);
        }
    } else {
        applicationDescButtonModel.setSelected(true);
    }

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

示例2: testJRadioButtonMenuItemStringIconBoolean

import javax.swing.JToggleButton.ToggleButtonModel; //导入依赖的package包/类
public void testJRadioButtonMenuItemStringIconBoolean() {
    Icon icon = createNewIcon();
    String text = "texttext";
    menuItem = new JRadioButtonMenuItem(text, icon, true);
    assertTrue("default buttonModel ", button.getModel() instanceof ToggleButtonModel);
    assertEquals("icon ", icon, menuItem.getIcon());
    assertEquals("text ", text, menuItem.getText());
    assertFalse("default FocusPainted", menuItem.isFocusPainted());
    assertTrue(menuItem.isSelected());
    assertEquals(SwingConstants.LEADING, button.getHorizontalAlignment());
    assertEquals(SwingConstants.TRAILING, button.getHorizontalTextPosition());
    assertEquals(SwingConstants.CENTER, button.getVerticalAlignment());
    assertEquals(SwingConstants.CENTER, button.getVerticalTextPosition());
    menuItem = new JRadioButtonMenuItem(text, icon, false);
    assertFalse(menuItem.isSelected());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:17,代码来源:JRadioButtonMenuItemTest.java

示例3: testJCheckBoxMenuItemStringIconBoolean

import javax.swing.JToggleButton.ToggleButtonModel; //导入依赖的package包/类
public void testJCheckBoxMenuItemStringIconBoolean() {
    Icon icon = createNewIcon();
    String text = "texttext";
    menuItem = new JCheckBoxMenuItem(text, icon, true);
    assertTrue("default buttonModel ", button.getModel() instanceof ToggleButtonModel);
    assertEquals("icon ", icon, menuItem.getIcon());
    assertEquals("text ", text, menuItem.getText());
    assertFalse("default FocusPainted", menuItem.isFocusPainted());
    assertTrue(menuItem.isSelected());
    assertEquals(SwingConstants.LEADING, button.getHorizontalAlignment());
    assertEquals(SwingConstants.TRAILING, button.getHorizontalTextPosition());
    assertEquals(SwingConstants.CENTER, button.getVerticalAlignment());
    assertEquals(SwingConstants.CENTER, button.getVerticalTextPosition());
    menuItem = new JCheckBoxMenuItem(text, icon, false);
    assertFalse(menuItem.isSelected());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:17,代码来源:JCheckBoxMenuItemTest.java

示例4: MachineSimulatorDocument

import javax.swing.JToggleButton.ToggleButtonModel; //导入依赖的package包/类
/** 
   * Primary constructor 
   * @param url The URL of the file to load into the new document.
   */
  public MachineSimulatorDocument( final java.net.URL url ) {
  	setSource( url );
  	//initialize the buttons
USE_DESIGN = new ToggleButtonModel();
USE_RF_DESIGN = new ToggleButtonModel();
USE_CHANNEL= new ToggleButtonModel();
USE_PVLOGGER = new ToggleButtonModel();
USE_LOGGEDBEND = new ToggleButtonModel();
USE_READ_BACK= new ToggleButtonModel();
USE_SET= new ToggleButtonModel();

WINDOW_REFERENCE = getDefaultWindowReference( "MainWindow", this );

PV_LOG_CHOOSER = new PVLogSnapshotChooser( mainWindow, true );

    // initialize the model here
    MODEL = new MachineModel();
MACHINE_SIMULATOR_CONTROLLER = new MachineSimulatorController( this,WINDOW_REFERENCE );

if ( url != null ) {
          System.out.println( "Opening document: " + url.toString() );
          final DataAdaptor documentAdaptor = XmlDataAdaptor.adaptorForUrl( url, false );
          update( documentAdaptor.childAdaptor( dataLabel() ) );
      }

setHasChanges( false );
  }
 
开发者ID:openxal,项目名称:openxal,代码行数:32,代码来源:MachineSimulatorDocument.java

示例5: customizeCommands

import javax.swing.JToggleButton.ToggleButtonModel; //导入依赖的package包/类
/**
 * Register actions specific to this window instance. This code demonstrates
 * how to define custom actions for menus and the toolbar for a particular
 * window instance. This method is optional. You may similarly define
 * actions in the document class if those actions are document specific and
 * also for the entire application if the actions are application wide.
 * 
 * @param commander
 *            The commander with which to register the custom commands.
 */
protected void customizeCommands(final Commander commander) {
	// define a toggle "edit" action
	final ToggleButtonModel editModel = new ToggleButtonModel();
	editModel.setSelected(true);
	editModel.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent event) {
			textView.setEditable(editModel.isSelected());
			Logger.getLogger("global").log(Level.INFO,
					"Toggle whether text is editable.");
			System.out.println("toggled editable...");
		}
	});
	commander.registerModel("toggle-editable", editModel);
}
 
开发者ID:openxal,项目名称:openxal,代码行数:25,代码来源:PrefWindow.java

示例6: customizeCommands

import javax.swing.JToggleButton.ToggleButtonModel; //导入依赖的package包/类
/**
 * Register actions specific to this window instance. This code demonstrates
 * how to define custom actions for menus and the toolbar for a particular
 * window instance. This method is optional. You may similarly define
 * actions in the document class if those actions are document specific and
 * also for the entire application if the actions are application wide.
 * 
 * @param commander
 *            The commander with which to register the custom commands.
 */
public void customizeCommands(final Commander commander) {
	// define a toggle "edit" action
	final ToggleButtonModel editModel = new ToggleButtonModel();
	editModel.setSelected(true);
	editModel.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent event) {
			textView.setEditable(editModel.isSelected());
			Logger.getLogger("global").log(Level.INFO,
					"Toggle whether text is editable.");
			System.out.println("toggled editable...");
		}
	});
	commander.registerModel("toggle-editable", editModel);
}
 
开发者ID:openxal,项目名称:openxal,代码行数:25,代码来源:EAWindow.java

示例7: AudioScopeProbe

import javax.swing.JToggleButton.ToggleButtonModel; //导入依赖的package包/类
public AudioScopeProbe(AudioScopeModel audioScopeModel, UnitOutputPort source, int partIndex) {
    this.audioScopeModel = audioScopeModel;
    this.source = source;
    this.partIndex = partIndex;

    verticalScaleModel = new ExponentialRangeModel("VScale", 1000, MIN_RANGE, MAX_RANGE,
            MIN_RANGE);
    autoScaleButtonModel = new ToggleButtonModel();
    autoScaleButtonModel.setSelected(true);
}
 
开发者ID:philburk,项目名称:jsyn,代码行数:11,代码来源:AudioScopeProbe.java

示例8: ScopeProbePanel

import javax.swing.JToggleButton.ToggleButtonModel; //导入依赖的package包/类
public ScopeProbePanel(AudioScopeProbeView probeView) {
    this.audioScopeProbeView = probeView;
    setLayout(new BorderLayout());

    setBorder(BorderFactory.createLineBorder(Color.GRAY, 3));

    // Add a colored box to match the waveform color.
    JPanel colorPanel = new JPanel();
    colorPanel.setMinimumSize(new Dimension(40, 40));
    audioScopeProbe = probeView.getModel();
    colorPanel.setBackground(audioScopeProbe.getColor());
    add(colorPanel, BorderLayout.NORTH);

    // Knob for tweaking vertical range.
    verticalScaleKnob = new RotaryTextController(audioScopeProbeView.getWaveTraceView()
            .getVerticalRangeModel(), 5);
    add(verticalScaleKnob, BorderLayout.CENTER);
    verticalScaleKnob.setTitle("YScale");

    // Auto ranging checkbox.
    autoBox = new JCheckBox("Auto");
    autoScaleModel = audioScopeProbeView.getWaveTraceView().getAutoButtonModel();
    autoScaleModel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            ToggleButtonModel model = (ToggleButtonModel) e.getSource();
            boolean enabled = !model.isSelected();
            System.out.println("Knob enabled = " + enabled);
            verticalScaleKnob.setEnabled(!model.isSelected());
        }
    });
    autoBox.setModel(autoScaleModel);
    add(autoBox, BorderLayout.SOUTH);

    verticalScaleKnob.setEnabled(!autoScaleModel.isSelected());

    setMinimumSize(new Dimension(80, 100));
    setPreferredSize(new Dimension(80, 150));
    setMaximumSize(new Dimension(120, 200));
}
 
开发者ID:philburk,项目名称:jsyn,代码行数:41,代码来源:ScopeProbePanel.java

示例9: createInputCheckBoxComponent

import javax.swing.JToggleButton.ToggleButtonModel; //导入依赖的package包/类
public static Component createInputCheckBoxComponent(final Object model,
                                             final AttributeSet attrs) {
    ToggleButtonModel checkBoxModel = (ToggleButtonModel) model;
    final JCheckBox checkBox = new JCheckBox();

    // Model
    if (checkBoxModel == null) {
        checkBoxModel = new FormToggleButtonModel(new Form(SimpleAttributeSet.EMPTY),
                                                  SimpleAttributeSet.EMPTY);
    }
    checkBox.setModel(checkBoxModel);

    // SIZE
    setButtonSize(checkBox, attrs);

    // TITLE
    setTitle(checkBox, attrs);

    // CHECKED
    setChecked(checkBox, attrs);

    // ACCESSKEY
    setButtonAccessKey(checkBox, attrs);

    // ALIGN
    setButtonAlign(checkBox);

    // DISABLED
    setDisabled(checkBox, attrs);

    return checkBox;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:33,代码来源:FormViewComponentFactory.java

示例10: testJRadioButtonMenuItem

import javax.swing.JToggleButton.ToggleButtonModel; //导入依赖的package包/类
public void testJRadioButtonMenuItem() {
    assertFalse(menuItem.isSelected());
    assertTrue("default buttonModel ", button.getModel() instanceof ToggleButtonModel);
    assertNull("icon ", button.getIcon());
    assertEquals("text ", "", button.getText());
    assertFalse("default FocusPainted", menuItem.isFocusPainted());
    assertEquals(SwingConstants.LEADING, button.getHorizontalAlignment());
    assertEquals(SwingConstants.TRAILING, button.getHorizontalTextPosition());
    assertEquals(SwingConstants.CENTER, button.getVerticalAlignment());
    assertEquals(SwingConstants.CENTER, button.getVerticalTextPosition());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:12,代码来源:JRadioButtonMenuItemTest.java

示例11: testJRadioButtonMenuItemIcon

import javax.swing.JToggleButton.ToggleButtonModel; //导入依赖的package包/类
public void testJRadioButtonMenuItemIcon() {
    Icon icon = createNewIcon();
    menuItem = new JRadioButtonMenuItem(icon);
    assertTrue("default buttonModel ", button.getModel() instanceof ToggleButtonModel);
    assertEquals("icon ", icon, menuItem.getIcon());
    assertEquals("text ", "", menuItem.getText());
    assertFalse("default FocusPainted", menuItem.isFocusPainted());
    assertEquals(SwingConstants.LEADING, button.getHorizontalAlignment());
    assertEquals(SwingConstants.TRAILING, button.getHorizontalTextPosition());
    assertEquals(SwingConstants.CENTER, button.getVerticalAlignment());
    assertEquals(SwingConstants.CENTER, button.getVerticalTextPosition());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:13,代码来源:JRadioButtonMenuItemTest.java

示例12: testJRadioButtonMenuItemString

import javax.swing.JToggleButton.ToggleButtonModel; //导入依赖的package包/类
public void testJRadioButtonMenuItemString() {
    String text = "texttext";
    menuItem = new JRadioButtonMenuItem(text);
    assertFalse(menuItem.isSelected());
    assertTrue("default buttonModel ", button.getModel() instanceof ToggleButtonModel);
    assertNull("icon ", menuItem.getIcon());
    assertEquals("text ", text, menuItem.getText());
    assertEquals(SwingConstants.LEADING, button.getHorizontalAlignment());
    assertEquals(SwingConstants.TRAILING, button.getHorizontalTextPosition());
    assertEquals(SwingConstants.CENTER, button.getVerticalAlignment());
    assertEquals(SwingConstants.CENTER, button.getVerticalTextPosition());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:13,代码来源:JRadioButtonMenuItemTest.java

示例13: testJRadioButtonMenuItemStringIcon

import javax.swing.JToggleButton.ToggleButtonModel; //导入依赖的package包/类
public void testJRadioButtonMenuItemStringIcon() {
    Icon icon = createNewIcon();
    String text = "texttext";
    menuItem = new JRadioButtonMenuItem(text, icon);
    assertFalse(menuItem.isSelected());
    assertTrue("default buttonModel ", button.getModel() instanceof ToggleButtonModel);
    assertEquals("icon ", icon, menuItem.getIcon());
    assertEquals("text ", text, menuItem.getText());
    assertFalse("default FocusPainted", menuItem.isFocusPainted());
    assertEquals(SwingConstants.LEADING, button.getHorizontalAlignment());
    assertEquals(SwingConstants.TRAILING, button.getHorizontalTextPosition());
    assertEquals(SwingConstants.CENTER, button.getVerticalAlignment());
    assertEquals(SwingConstants.CENTER, button.getVerticalTextPosition());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:15,代码来源:JRadioButtonMenuItemTest.java

示例14: testJRadioButtonMenuItemIconBoolean

import javax.swing.JToggleButton.ToggleButtonModel; //导入依赖的package包/类
public void testJRadioButtonMenuItemIconBoolean() {
    Icon icon = createNewIcon();
    menuItem = new JRadioButtonMenuItem(icon, true);
    assertTrue("default buttonModel ", button.getModel() instanceof ToggleButtonModel);
    assertEquals("icon ", icon, menuItem.getIcon());
    assertEquals("text ", "", menuItem.getText());
    assertFalse("default FocusPainted", menuItem.isFocusPainted());
    assertTrue(menuItem.isSelected());
    assertEquals(SwingConstants.LEADING, button.getHorizontalAlignment());
    assertEquals(SwingConstants.TRAILING, button.getHorizontalTextPosition());
    assertEquals(SwingConstants.CENTER, button.getVerticalAlignment());
    assertEquals(SwingConstants.CENTER, button.getVerticalTextPosition());
    menuItem = new JRadioButtonMenuItem(icon, false);
    assertFalse(menuItem.isSelected());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:16,代码来源:JRadioButtonMenuItemTest.java

示例15: testJCheckBoxMenuItem

import javax.swing.JToggleButton.ToggleButtonModel; //导入依赖的package包/类
public void testJCheckBoxMenuItem() {
    assertFalse(menuItem.isSelected());
    assertTrue("default buttonModel ", button.getModel() instanceof ToggleButtonModel);
    assertNull("icon ", button.getIcon());
    assertEquals("text ", "", button.getText());
    assertFalse("default FocusPainted", menuItem.isFocusPainted());
    assertEquals(SwingConstants.LEADING, button.getHorizontalAlignment());
    assertEquals(SwingConstants.TRAILING, button.getHorizontalTextPosition());
    assertEquals(SwingConstants.CENTER, button.getVerticalAlignment());
    assertEquals(SwingConstants.CENTER, button.getVerticalTextPosition());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:12,代码来源:JCheckBoxMenuItemTest.java


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