本文整理了Java中java.awt.Checkbox
类的一些代码示例,展示了Checkbox
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Checkbox
类的具体详情如下:
包路径:java.awt.Checkbox
类名称:Checkbox
暂无
代码示例来源:origin: stackoverflow.com
if (obj instanceof Checkbox)
{
Checkbox cb = (Checkbox)obj;
boolean state = cb.getState();
}
代码示例来源:origin: sc.fiji/MTrackJ_
public void addCheckbox(String label, boolean defaultValue) {
String label2 = label;
if (label2.indexOf('_')!=-1) label2 = label2.replace('_', ' ');
if (checkbox==null) {
checkbox = new Vector(4);
c.insets = getInsets(10,10,0,0);
} else c.insets = getInsets(0,10,0,0);
c.gridx = 0; c.gridy = y;
c.gridwidth = 2;
c.anchor = GridBagConstraints.WEST;
Checkbox cb = new Checkbox(" "+label2);
cb.setFont(font);
grid.setConstraints(cb, c);
cb.setState(defaultValue);
cb.addItemListener(this);
cb.addKeyListener(this);
add(cb);
checkbox.addElement(cb);
y++;
}
代码示例来源:origin: net.imagej/ij
c.gridx = 0; c.gridy++;
if (checkbox==null)
c.insets = getInsets(15, 20, 0, 0); // top, left, bottom, right
else
c.insets = getInsets(0, 20, 0, 0);
checkbox = new Vector(4);
Checkbox cb = new Checkbox(label2);
cb.setState(defaultValue);
cb.addItemListener(this);
cb.addKeyListener(this);
add(cb, c);
c.insets.left = 0;
checkbox.addElement(cb);
if (!isPreview &&(Recorder.record || macro)) //preview checkbox is not recordable
saveLabel(cb, label);
代码示例来源:origin: net.imagej/ij
/** Notify any DialogListeners of changes having occurred
* If a listener returns false, do not call further listeners and disable
* the OK button and preview Checkbox (if it exists).
* For PlugInFilters, this ensures that the PlugInFilterRunner,
* which listens as the last one, is not called if the PlugInFilter has
* detected invalid parameters. Thus, unnecessary calling the run(ip) method
* of the PlugInFilter for preview is avoided in that case.
*/
private void notifyListeners(AWTEvent e) {
if (dialogListeners==null)
return;
boolean everythingOk = true;
for (int i=0; everythingOk && i<dialogListeners.size(); i++)
try {
resetCounters();
if (!((DialogListener)dialogListeners.elementAt(i)).dialogItemChanged(this, e))
everythingOk = false; } // disable further listeners if false (invalid parameters) returned
catch (Exception err) { // for exceptions, don't cover the input by a window but
IJ.beep(); // show them at in the "Log"
IJ.log("ERROR: "+err+"\nin DialogListener of "+dialogListeners.elementAt(i)+
"\nat "+(err.getStackTrace()[0])+"\nfrom "+(err.getStackTrace()[1])); //requires Java 1.4
}
boolean workaroundOSXbug = IJ.isMacOSX() && okay!=null && !okay.isEnabled() && everythingOk;
if (previewCheckbox!=null)
previewCheckbox.setEnabled(everythingOk);
if (okay!=null)
okay.setEnabled(everythingOk);
if (workaroundOSXbug)
repaint(); // OSX 10.4 bug delays update of enabled until the next input
}
代码示例来源:origin: sc.fiji/Trainable_Segmentation
/**
* Disables features which rely on missing third party libraries.
* @param gd settings dialog
* */
public static void disableMissingFeatures(final GenericDialog gd)
{
if (!isImageScienceAvailable()) {
IJ.log("Warning: ImageScience library unavailable. " +
"Some training features will be disabled.");
@SuppressWarnings("unchecked")
final Vector<Checkbox> v = gd.getCheckboxes();
for (int i = 0; i < v.size(); i++) {
if (FeatureStack.IMAGESCIENCE_FEATURES[i]) {
v.get(i).setState(false);
v.get(i).setEnabled(false);
}
}
}
}
代码示例来源:origin: net.imagej/ij
if (!cCursor.getState()) return;
if (vwins == null) return;
ImagePlus imp;
ImageWindow iwc = (ImageWindow) icc.getParent();
for(int n=0; n<vwins.size();++n) {
iw = imp.getWindow();
if(iw != iwc) {
ic = iw.getCanvas();
if (cCoords.getState()) {
p = getMatchingCoords(ic, icc, x, y);
代码示例来源:origin: sc.fiji/Simple_Neurite_Tracer
@Override
public boolean dialogItemChanged(final GenericDialog arg, final AWTEvent event) {
useOnlySelectedPaths = gd.getNextRadioButton().contains("only");
restrictByRoi = gd.getNextRadioButton().contains("only");
restrictBySWCType = gd.getNextRadioButton().contains("only");
final String analysisChoice = gd.getNextRadioButton();
summarizeSkeleton = analysisChoice.contains("summary");
callAnalyzeSkeleton = analysisChoice.contains("Analyze Skeleton");
if (restrictBySWCType) {
selectedSwcTypes.clear();
for (final int type : Path.getSWCtypes()) {
if (gd.getNextBoolean())
selectedSwcTypes.add(type);
}
}
final Vector<?> cbxs = gd.getCheckboxes();
for (int i = 0; i < cbxs.size(); i++)
((Checkbox) cbxs.get(i)).setEnabled(restrictBySWCType);
return true;
}
代码示例来源:origin: sc.fiji/MTrackJ_
public boolean getNextBoolean() {
if (checkbox==null) return false;
Checkbox cb = (Checkbox)(checkbox.elementAt(cbIndex));
boolean state = cb.getState();
cbIndex++;
return state;
}
代码示例来源:origin: net.imagej/ij
public String commandExecuting(String command) {
if (vwins!=null && cScaling!=null && cScaling.getState() && ("In [+]".equals(command) || "Out [-]".equals(command))) {
ImagePlus imp = WindowManager.getCurrentImage();
ImageCanvas cic = imp!=null?imp.getCanvas():null;
if (cic==null)
return command;
for (int i=0; i<vwins.size(); i++) {
imp = getImageFromVector(i);
if (imp!=null) {
ImageCanvas ic = imp.getCanvas();
if (ic!=cic) {
if ("In [+]".equals(command))
ic.zoomOut(sx, sy);
if (ic.getMagnification()<=1.0)
imp.repaintWindow();
代码示例来源:origin: net.imagej/ij
public boolean dialogItemChanged(GenericDialog gd, AWTEvent e) {
if (gd.wasCanceled()) return false;
String colorName2 = colorName;
boolean showLabels2 = showLabels;
boolean bold2 = bold;
int fontSize2 = fontSize;
colorName = gd.getNextChoice();
fontSize = (int)Tools.parseDouble(gd.getNextChoice(), 12);
showLabels = gd.getNextBoolean();
showNames = gd.getNextBoolean();
showLabels = true;
Vector checkboxes = gd.getCheckboxes();
((Checkbox)checkboxes.elementAt(0)).setState(true);
overlay.setLabelFont(new Font("SansSerif", bold?Font.BOLD:Font.PLAIN, fontSize));
if (imp!=null) {
Overlay o = imp.getOverlay();
if (o==null) {
ImageCanvas ic = imp.getCanvas();
if (ic!=null)
o = ic.getShowAllList();
imp.draw();
代码示例来源:origin: net.imagej/ij
/** Read the parameters (during preview or after showing the dialog) */
public boolean dialogItemChanged(GenericDialog gd, AWTEvent e) {
tolerance = gd.getNextNumber();
if (tolerance<0) tolerance = 0;
dialogOutputType = gd.getNextChoiceIndex();
outputType = previewing ? POINT_SELECTION : dialogOutputType;
excludeOnEdges = gd.getNextBoolean();
if (thresholded)
useMinThreshold = gd.getNextBoolean();
else
useMinThreshold = false;
lightBackground = gd.getNextBoolean();
boolean invertedLut = imp.isInvertedLut();
if (useMinThreshold && ((invertedLut&&!lightBackground) || (!invertedLut&&lightBackground))) {
if (!thresholdWarningShown)
if (!IJ.showMessageWithCancel(
"Find Maxima",
"\"Above Lower Threshold\" option cannot be used\n"+
"when finding minima (image with light background\n"+
"or image with dark background and inverting LUT).")
&& !previewing)
return false; // if faulty input is not detected during preview, "cancel" quits
thresholdWarningShown = true;
useMinThreshold = false;
((Checkbox)(checkboxes.elementAt(1))).setState(false); //reset "Above Lower Threshold" checkbox
}
if (!gd.isPreviewActive())
messageArea.setText(""); // no "nnn Maxima" message when not previewing
return (!gd.invalidNumber());
} // public boolean DialogItemChanged
代码示例来源:origin: net.imagej/ij
String showDialog(ImagePlus imp, String dialogTitle, String prompt) {
int stackSize = imp.getStackSize();
String options = Macro.getOptions();
boolean isMacro = options!=null;
String title = getNewTitle();
if (title==null) title=defaultTitle;
GenericDialog gd = new GenericDialog(dialogTitle);
this.gd = gd;
gd.addStringField(prompt, title, 15);
if (stackSize>1) {
gd.addCheckbox("Duplicate stack", duplicateStack);
gd.setInsets(2, 30, 3);
gd.addStringField("Range:", "1-"+stackSize);
if (!isMacro) {
checkbox = (Checkbox)(gd.getCheckboxes().elementAt(0));
checkbox.addItemListener(this);
Vector v = gd.getStringFields();
titleField = (TextField)v.elementAt(0);
rangeField = (TextField)v.elementAt(1);
titleField.addTextListener(this);
rangeField.addTextListener(this);
代码示例来源:origin: net.imagej/ij
public void itemStateChanged(ItemEvent e) {
if (IJ.isMacOSX()) IJ.wait(100);
Checkbox cb = (Checkbox)checkboxes.elementAt(2);
nointerpolate = cb.getState();
updateSize();
}
代码示例来源:origin: net.imagej/ij
/** Returns the state of the next checkbox. */
public boolean getNextBoolean() {
if (checkbox==null)
return false;
Checkbox cb = (Checkbox)(checkbox.elementAt(cbIndex));
if (recorderOn)
recordCheckboxOption(cb);
boolean state = cb.getState();
if (macro) {
String label = (String)labels.get((Object)cb);
String key = Macro.trimKey(label);
state = isMatch(macroOptions, key+" ");
}
cbIndex++;
return state;
}
代码示例来源:origin: net.imagej/ij
/** Returns the selected item in the next radio button group. */
public String getNextRadioButton() {
if (radioButtonGroups==null)
return null;
CheckboxGroup cg = (CheckboxGroup)(radioButtonGroups.elementAt(radioButtonIndex));
radioButtonIndex++;
Checkbox checkbox = cg.getSelectedCheckbox();
String item = "null";
if (checkbox!=null)
item = checkbox.getLabel();
if (macro) {
String label = (String)labels.get((Object)cg);
item = Macro.getValue(macroOptions, label, item);
}
if (recorderOn)
recordOption(cg, item);
return item;
}
代码示例来源:origin: zitmen/thunderstorm
/** Read the parameters (during preview or after showing the dialog) */
public boolean dialogItemChanged(GenericDialog gd, AWTEvent e) {
tolerance = gd.getNextNumber();
if (tolerance<0) tolerance = 0;
dialogOutputType = gd.getNextChoiceIndex();
outputType = previewing ? POINT_SELECTION : dialogOutputType;
excludeOnEdges = gd.getNextBoolean();
if (thresholded)
useMinThreshold = gd.getNextBoolean();
else
useMinThreshold = false;
lightBackground = gd.getNextBoolean();
boolean invertedLut = imp.isInvertedLut();
if (useMinThreshold && ((invertedLut&&!lightBackground) || (!invertedLut&&lightBackground))) {
if (!thresholdWarningShown)
if (!IJ.showMessageWithCancel(
"Find Maxima",
"\"Above Lower Threshold\" option cannot be used\n"+
"when finding minima (image with light background\n"+
"or image with dark background and inverting LUT).")
&& !previewing)
return false; // if faulty input is not detected during preview, "cancel" quits
thresholdWarningShown = true;
useMinThreshold = false;
((Checkbox)(checkboxes.elementAt(1))).setState(false); //reset "Above Lower Threshold" checkbox
}
if (!gd.getPreviewCheckbox().getState())
messageArea.setText(""); // no "nnn Maxima" message when not previewing
return (!gd.invalidNumber());
} // public boolean DialogItemChanged
代码示例来源:origin: sc.fiji/3D_Viewer
@Override
public void windowClosed(final WindowEvent e) {
if (null != transp_adjuster) transp_adjuster.quit();
if (gd.wasCanceled()) {
final float newTr = oldTr / 100f;
ci.setTransparency(newTr);
univ.fireContentChanged(c);
return;
}
// apply to all instants of the content
if (aBox.getState()) c.setTransparency(ci.getTransparency());
record(SET_TRANSPARENCY, Float.toString(((Scrollbar) gd.getSliders()
.get(0)).getValue() / 100f));
}
});
代码示例来源:origin: net.imagej/ij
/** Overrides PlugInFrame.close(). */
public void close() {
super.close();
instance = null;
resetMultiMeasureResults();
Prefs.saveLocation(LOC_KEY, getLocation());
if (!showAllCheckbox.getState() || IJ.macroRunning())
return;
int n = getCount();
ImagePlus imp = WindowManager.getCurrentImage();
if (imp==null || (imp.getCanvas()!=null && imp.getCanvas().getShowAllList()==null))
return;
if (n>0) {
GenericDialog gd = new GenericDialog("ROI Manager");
gd.addMessage("Save the "+n+" displayed ROIs as an overlay?");
gd.setOKLabel("Discard");
gd.setCancelLabel("Save as Overlay");
gd.showDialog();
if (gd.wasCanceled())
moveRoisToOverlay(imp);
else
removeOverlay(imp);
} else
imp.draw();
}
代码示例来源:origin: net.imagej/ij
public boolean dialogItemChanged(GenericDialog gd, AWTEvent e) {
int width = imp.getWidth();
int height = imp.getHeight();
type = gd.getNextChoice();
areaPerPoint = gd.getNextNumber();
color = gd.getNextChoice();
bold = gd.getNextBoolean();
centered = gd.getNextBoolean();
centered = false;
if (centerCheckbox!=null)
centerCheckbox.setState(false);
String err = "\"Area per Point\" too small";
if (gd.wasOKed())
IJ.error("Grid", err);
else
IJ.showStatus(err);
return true;
代码示例来源:origin: net.imagej/ij
private String getNewTitle() {
if (titleChanged)
return null;
String title = defaultTitle;
if (imp.getStackSize()>1 && !duplicateStack && !legacyMacro && (checkbox==null||!checkbox.getState())) {
ImageStack stack = imp.getStack();
String label = stack.getShortSliceLabel(imp.getCurrentSlice());
if (label!=null && label.length()==0)
label = null;
if (label!=null) {
title = label;
sliceLabel = label;
}
}
return title;
}
内容来源于网络,如有侵权,请联系作者删除!