本文整理汇总了Java中java.awt.Checkbox.addItemListener方法的典型用法代码示例。如果您正苦于以下问题:Java Checkbox.addItemListener方法的具体用法?Java Checkbox.addItemListener怎么用?Java Checkbox.addItemListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Checkbox
的用法示例。
在下文中一共展示了Checkbox.addItemListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addEnablerListener
import java.awt.Checkbox; //导入方法依赖的package包/类
/** A helper for GenericDialog checkboxes to control other the enabled state of other GUI elements in the same dialog. */
static public final void addEnablerListener(final Checkbox master, final Component[] enable, final Component[] disable) {
master.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent ie) {
if (ie.getStateChange() == ItemEvent.SELECTED) {
process(enable, true);
process(disable, false);
} else {
process(enable, false);
process(disable, true);
}
}
private void process(final Component[] c, final boolean state) {
if (null == c) return;
for (int i=0; i<c.length; i++) c[i].setEnabled(state);
}
});
}
示例2: DrawControls
import java.awt.Checkbox; //导入方法依赖的package包/类
@SuppressWarnings("LeakingThisInConstructor")
public DrawControls(DrawPanel target) {
this.target = target;
setLayout(new FlowLayout());
setBackground(Color.lightGray);
target.setForeground(Color.red);
CheckboxGroup group = new CheckboxGroup();
Checkbox b;
add(b = new Checkbox(null, group, false));
b.addItemListener(this);
b.setForeground(Color.red);
add(b = new Checkbox(null, group, false));
b.addItemListener(this);
b.setForeground(Color.green);
add(b = new Checkbox(null, group, false));
b.addItemListener(this);
b.setForeground(Color.blue);
add(b = new Checkbox(null, group, false));
b.addItemListener(this);
b.setForeground(Color.pink);
add(b = new Checkbox(null, group, false));
b.addItemListener(this);
b.setForeground(Color.orange);
add(b = new Checkbox(null, group, true));
b.addItemListener(this);
b.setForeground(Color.black);
target.setForeground(b.getForeground());
Choice shapes = new Choice();
shapes.addItemListener(this);
shapes.addItem("Lines");
shapes.addItem("Points");
shapes.setBackground(Color.lightGray);
add(shapes);
}
示例3: init
import java.awt.Checkbox; //导入方法依赖的package包/类
public void init ()
{
initted = true;
text = new TextField ("hello world");
add (text, "North");
Panel p = new Panel();
p.setLayout (new GridLayout (3, 1));
((GridLayout) p.getLayout ()).setHgap (5);
((GridLayout) p.getLayout ()).setVgap (5);
editable = new Checkbox("Editable", true);
p.add (editable);
editable.addItemListener (this);
visible = new Checkbox("Visible", true);
p.add (visible);
visible.addItemListener (this);
sensitive = new Checkbox("Sensitive", true);
p.add (sensitive);
sensitive.addItemListener (this);
add (p, "Center");
Button cb = new Button ("Close");
cb.addActionListener(new ActionListener () {
public void actionPerformed (ActionEvent e) {
dispose();
}
});
add (cb, "South");
setTitle ("TextField");
pack();
}
示例4: init
import java.awt.Checkbox; //导入方法依赖的package包/类
public void init ()
{
initted = true;
text = new TextField ("hello world");
add (text, "North");
Panel p = new Panel();
p.setLayout (new GridLayout (3, 1));
((GridLayout) p.getLayout ()).setHgap (5);
((GridLayout) p.getLayout ()).setVgap (5);
editable = new Checkbox("Editable", true);
p.add (editable);
editable.addItemListener (this);
visible = new Checkbox("Visible", true);
p.add (visible);
visible.addItemListener (this);
sensitive = new Checkbox("Sensitive", true);
p.add (sensitive);
sensitive.addItemListener (this);
add (p, "Center");
Button cb = new Button ("Close");
cb.addActionListener(new ActionListener () {
public void actionPerformed (ActionEvent e) {
dispose();
}
});
add (cb, "South");
setTitle ("TextField");
pack();
}
示例5: createCheckbox
import java.awt.Checkbox; //导入方法依赖的package包/类
protected Checkbox createCheckbox(String label, final int item) {
Checkbox check = new Checkbox(label);
check.addItemListener(new ItemListener() {
@Override
@SuppressWarnings("static-access")
public void itemStateChanged(ItemEvent ie) {
setSwitch(item, (ie.getStateChange() == ie.SELECTED));
}
});
return check;
}
示例6: wireComponent
import java.awt.Checkbox; //导入方法依赖的package包/类
@Override
protected void wireComponent(final ComponentContext context) {
super.wireComponent(context);
final Checkbox component = (Checkbox) context.getComponent();
final MethodListenerProxy<ItemListener> itemListener = new MethodListenerProxy<ItemListener>(
ItemListener.class, context.getActionListeners());
if (itemListener.hasListeningMethod()) {
component.addItemListener(itemListener.getProxy());
}
}
示例7: showDialog
import java.awt.Checkbox; //导入方法依赖的package包/类
private boolean showDialog()
{
GenericDialog gd = new GenericDialog(TITLE);
gd.addHelp(About.HELP_URL);
gd.addMessage(
"Create a set of filters for use in the Filter Analysis plugin.\nAttributes will be enumerated if they are of the form 'min:max:increment'");
filterSettings = SettingsManager.readGUIFilterSettings(0).toBuilder();
gd.addTextAreas(filterSettings.getFilterTemplate(), null, 20, 80);
gd.addCheckbox("Enumerate_early attributes first", enumerateEarly);
gd.addCheckbox("Show_demo_filters", false);
if (Utils.isShowGenericDialog())
{
Checkbox cb = (Checkbox) gd.getCheckboxes().get(1);
cb.addItemListener(this);
}
gd.showDialog();
if (gd.wasCanceled())
return false;
filterSettings.setFilterTemplate(gd.getNextText());
enumerateEarly = gd.getNextBoolean();
boolean demoFilters = gd.getNextBoolean();
if (demoFilters)
{
logDemoFilters();
return false;
}
return SettingsManager.writeSettings(filterSettings.build());
}
示例8: addEnablerListener
import java.awt.Checkbox; //导入方法依赖的package包/类
public static final void addEnablerListener(/* final GenericDialog gd, */final Checkbox master, final Component[] enable, final Component[] disable)
{
master.addItemListener(new ItemListener()
{
@Override
public void itemStateChanged(ItemEvent ie)
{
if (ie.getStateChange() == ItemEvent.SELECTED)
{
process(enable, true);
process(disable, false);
}
else
{
process(enable, false);
process(disable, true);
}
}
private void process(final Component[] c, final boolean state)
{
if (null == c) return;
for (int i = 0; i < c.length; i++)
{
c[i].setEnabled(state);
// c[i].setVisible(state);
}
// gd.pack();
}
});
}
示例9: addInverseEnablerListener
import java.awt.Checkbox; //导入方法依赖的package包/类
public static final void addInverseEnablerListener(/* final GenericDialog gd, */final Checkbox master, final Component[] enable, final Component[] disable)
{
master.addItemListener(new ItemListener()
{
@Override
public void itemStateChanged(ItemEvent ie)
{
if (ie.getStateChange() == ItemEvent.SELECTED)
{
process(enable, false);
process(disable, true);
}
else
{
process(enable, true);
process(disable, false);
}
}
private void process(final Component[] c, final boolean state)
{
if (null == c) return;
for (int i = 0; i < c.length; i++)
{
c[i].setEnabled(state);
// c[i].setVisible(state);
}
// gd.pack();
}
});
}
示例10: run
import java.awt.Checkbox; //导入方法依赖的package包/类
public void run(String arg) {
if (!FJ.libcheck()) return;
final ImagePlus imp = FJ.imageplus();
if (imp == null) return;
FJ.log(FJ.name()+" "+FJ.version()+": Edges");
GenericDialog gd = new GenericDialog(FJ.name()+": Edges");
gd.addCheckbox(" Compute gradient-magnitude image ",compute);
gd.addStringField(" Smoothing scale:",scale);
gd.addPanel(new Panel(),GridBagConstraints.EAST,new Insets(0,0,0,0));
gd.addCheckbox(" Suppress non-maximum gradients ",suppress);
gd.addPanel(new Panel(),GridBagConstraints.EAST,new Insets(0,0,0,0));
gd.addStringField(" Lower threshold value:",lower);
gd.addStringField(" Higher threshold value:",higher);
computebox = (Checkbox)gd.getCheckboxes().get(0); computebox.addItemListener(this);
suppressbox = (Checkbox)gd.getCheckboxes().get(1); suppressbox.addItemListener(this);
if (pos.x >= 0 && pos.y >= 0) {
gd.centerDialog(false);
gd.setLocation(pos);
} else gd.centerDialog(true);
gd.addWindowListener(this);
gd.showDialog();
if (gd.wasCanceled()) return;
compute = gd.getNextBoolean();
scale = gd.getNextString();
suppress = gd.getNextBoolean();
lower = gd.getNextString();
higher = gd.getNextString();
(new FJEdges()).run(imp,compute,scale,suppress,lower,higher);
}
示例11: ConsultarPrestamo
import java.awt.Checkbox; //导入方法依赖的package包/类
public ConsultarPrestamo(Connection conn, JFrameJTable principal, String sql) {
setIconImage(Toolkit.getDefaultToolkit().getImage(ConsultarPrestamo.class.getResource("/biblioteca/images/book.png")));
this.conn=conn;
this.principal=principal;
this.principal.setEnabled(false);
setTitle("Consultar pr�stamo");
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 703, 472);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
opciones=new CheckboxGroup();
tipo=new Checkbox("Tipo", opciones, false);
usuario=new Checkbox("Usuario",opciones,true);
tipo.addItemListener(this);
usuario.addItemListener(this);
tipo.setBounds(500, 20, 62, 23);
usuario.setBounds(500, 49, 62, 23);
contentPane.add(usuario);
contentPane.add(tipo);
txtUsuario = new JTextField();
txtUsuario.setBounds(10, 33, 465, 23);
contentPane.add(txtUsuario);
txtUsuario.setColumns(10);
txtUsuario.addKeyListener(this);
btnBuscar = new JButton("Buscar");
btnBuscar.setBounds(568, 33, 109, 23);
contentPane.add(btnBuscar);
btnBuscar.addActionListener(this);
table = new PanelJtable(conn,sql,this);
table.setBounds(10, 82, 667, 340);
contentPane.add(table);
addWindowListener(this);
setVisible(true);
setLocationRelativeTo(null);
}
示例12: showDialog
import java.awt.Checkbox; //导入方法依赖的package包/类
private boolean showDialog()
{
ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
gd.addHelp(About.HELP_URL);
gd.addMessage("Select a dataset to filter");
ResultsManager.addInput(gd, inputOption, InputSource.MEMORY);
filterSettings = SettingsManager.readGUIFilterSettings(0).toBuilder();
String text;
try
{
text = XmlUtils.prettyPrintXml(filterSettings.getFreeFilter());
}
catch (Exception e)
{
text = filterSettings.getFreeFilter();
}
gd.addTextAreas(text, null, 20, 80);
gd.addCheckbox("Show_demo_filters", false);
if (Utils.isShowGenericDialog())
{
Checkbox cb = (Checkbox) gd.getCheckboxes().get(0);
cb.addItemListener(this);
}
gd.showDialog();
if (gd.wasCanceled())
return false;
inputOption = ResultsManager.getInputSource(gd);
filterSettings.setFreeFilter(gd.getNextText());
boolean demoFilters = gd.getNextBoolean();
if (demoFilters)
{
logDemoFilters(TITLE);
return false;
}
return SettingsManager.writeSettings(filterSettings.build());
}
示例13: run
import java.awt.Checkbox; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public void run(String arg) {
if (!FJ.libcheck()) return;
final ImagePlus imp = FJ.imageplus();
if (imp == null) return;
FJ.log(FJ.name()+" "+FJ.version()+": Statistics");
GenericDialog gd = new GenericDialog(FJ.name()+": Statistics");
gd.addCheckboxGroup(7,2,labels,values);
gd.addPanel(new Panel(),GridBagConstraints.EAST,new Insets(5,0,0,0));
gd.addCheckbox(" Clear previous results",clear);
gd.addCheckbox(" Image name displaying",name);
gd.addCheckbox(" Channel numbering",channel);
gd.addCheckbox(" Time frame numbering",time);
gd.addCheckbox(" Slice numbering",slice);
final Vector checkboxes = gd.getCheckboxes();
final int veclen = checkboxes.size();
slicebox = (Checkbox)checkboxes.get(veclen-1); slicebox.addItemListener(this);
timebox = (Checkbox)checkboxes.get(veclen-2); timebox.addItemListener(this);
channelbox = (Checkbox)checkboxes.get(veclen-3); channelbox.addItemListener(this);
gd.addPanel(new Panel(),GridBagConstraints.EAST,new Insets(0,0,0,0));
final String[] decslist = new String[11];
for (int i=0; i<11; ++i) decslist[i] = String.valueOf(i);
gd.addChoice(" Decimal places:",decslist,String.valueOf(decimals));
if (pos.x >= 0 && pos.y >= 0) {
gd.centerDialog(false);
gd.setLocation(pos);
} else gd.centerDialog(true);
gd.addWindowListener(this);
gd.showDialog();
if (gd.wasCanceled()) return;
for (int i=0; i<values.length; ++i) values[i] = gd.getNextBoolean();
clear = gd.getNextBoolean();
name = gd.getNextBoolean();
channel = gd.getNextBoolean();
time = gd.getNextBoolean();
slice = gd.getNextBoolean();
decimals = gd.getNextChoiceIndex();
(new FJStatistics()).run(imp,values,clear,name,channel,time,slice,decimals);
}
示例14: BigDataViewerTransformationWindow
import java.awt.Checkbox; //导入方法依赖的package包/类
public BigDataViewerTransformationWindow( final BigDataViewer bdv )
{
this.t = new AffineTransform3D();
final Frame frame = new Frame( "Current Global Transformation" );
frame.setSize( 400, 200 );
/* Instantiation */
final GridBagLayout layout = new GridBagLayout();
final GridBagConstraints c = new GridBagConstraints();
final Label text1 = new Label( "1.00000 0.00000 0.00000 0.00000", Label.CENTER );
final Label text2 = new Label( "0.00000 1.00000 0.00000 0.00000", Label.CENTER );
final Label text3 = new Label( "0.00000 0.00000 1.00000 0.00000", Label.CENTER );
text1.setFont( new Font( Font.MONOSPACED, Font.PLAIN, 14 ) );
text2.setFont( new Font( Font.MONOSPACED, Font.PLAIN, 14 ) );
text3.setFont( new Font( Font.MONOSPACED, Font.PLAIN, 14 ) );
final Button apply = new Button( "Apply Transformation" );
final Button cancel = new Button( "Cancel" );
final Checkbox ignoreScale = new Checkbox( "Ignore scaling factor from BigDataViewer", ignoreScaling );
/* Location */
frame.setLayout( layout );
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy = 0;
frame.add( text1, c );
++c.gridy;
frame.add( text2, c );
++c.gridy;
frame.add( text3, c );
c.insets = new Insets( 20,0,0,0 );
++c.gridy;
frame.add( ignoreScale, c );
c.insets = new Insets( 20,0,0,0 );
++c.gridy;
frame.add( apply, c );
c.insets = new Insets( 0,0,0,0 );
++c.gridy;
frame.add( cancel, c );
apply.addActionListener( new ApplyButtonListener( frame, bdv ) );
cancel.addActionListener( new CancelButtonListener( frame, bdv ) );
ignoreScale.addItemListener( new ItemListener(){ public void itemStateChanged( final ItemEvent arg0 ) { ignoreScaling = ignoreScale.getState(); } });
frame.setVisible( true );
timer = new Timer();
timer.schedule( new BDVChecker( bdv, text1, text2, text3 ), 500 );
}
示例15: createFrame
import java.awt.Checkbox; //导入方法依赖的package包/类
private void createFrame()
{
Panel mainPanel = new Panel();
GridLayout mainGrid = new GridLayout(0, 1);
mainGrid.setHgap(10);
mainGrid.setVgap(10);
mainPanel.setLayout(mainGrid);
add(mainPanel);
pixelsLabel = new Label(pixelsUnitString, 0);
pixelsLabel.setFont(monoFont);
mainPanel.add(createLabelPanel(null, "Channel/frame options for stacks pop-up at run-time", null));
channel1List = new Choice();
mainPanel.add(createChoicePanel(channel1List, choiceChannel1));
channel2List = new Choice();
mainPanel.add(createChoicePanel(channel2List, choiceChannel2));
segmented1List = new Choice();
segmented1Option = new Choice();
mainPanel.add(createRoiChoicePanel(segmented1List, segmented1Option, choiceSegmentedChannel1,
segmented1OptionIndex));
segmented2List = new Choice();
segmented2Option = new Choice();
mainPanel.add(createRoiChoicePanel(segmented2List, segmented2Option, choiceSegmentedChannel2,
segmented2OptionIndex));
confinedList = new Choice();
confinedOption = new Choice();
mainPanel.add(createRoiChoicePanel(confinedList, confinedOption, choiceConfined, confinedOptionIndex));
expandConfinedCheckbox = new Checkbox();
mainPanel.add(createCheckboxPanel(expandConfinedCheckbox, choiceExpandConfined, expandConfinedCompartment));
maximumRadiusText = new TextField();
mainPanel.add(createTextPanel(maximumRadiusText, choiceMaximumRadius, "" + maximumRadius));
maximumRadiusText.addKeyListener(this);
randomRadiusText = new TextField();
mainPanel.add(createTextPanel(randomRadiusText, choiceRandomRadius, "" + randomRadius));
randomRadiusText.addKeyListener(this);
subRandomSamplesCheckbox = new Checkbox();
mainPanel.add(createCheckboxPanel(subRandomSamplesCheckbox, choiceSubRandomSamples, subRandomSamples));
subRandomSamplesCheckbox.addItemListener(this);
numberOfSamplesField = new Label();
mainPanel.add(createLabelPanel(numberOfSamplesField, numberOfSamplesLabel, ""));
updateNumberOfSamples();
binsText = new TextField();
mainPanel.add(createTextPanel(binsText, choiceBinsNumber, "" + histogramBins));
closeWindowsOnExitCheckbox = new Checkbox();
mainPanel.add(createCheckboxPanel(closeWindowsOnExitCheckbox, choiceCloseWindowsOnExit, closeWindowsOnExit));
setResultsOptionsCheckbox = new Checkbox();
mainPanel.add(createCheckboxPanel(setResultsOptionsCheckbox, choiceSetOptions, false));
setResultsOptionsCheckbox.addItemListener(this);
okButton = new Button(okButtonLabel);
okButton.addActionListener(this);
helpButton = new Button(helpButtonLabel);
helpButton.addActionListener(this);
JPanel buttonPanel = new JPanel();
FlowLayout l = new FlowLayout();
l.setVgap(0);
buttonPanel.setLayout(l);
buttonPanel.add(okButton, BorderLayout.CENTER);
buttonPanel.add(helpButton, BorderLayout.CENTER);
mainPanel.add(buttonPanel);
}