本文整理汇总了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);
}
}
示例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());
}
示例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());
}
示例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 );
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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;
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}