本文整理匯總了Java中java.awt.Choice類的典型用法代碼示例。如果您正苦於以下問題:Java Choice類的具體用法?Java Choice怎麽用?Java Choice使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Choice類屬於java.awt包,在下文中一共展示了Choice類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: GtkChoicePeer
import java.awt.Choice; //導入依賴的package包/類
public GtkChoicePeer (Choice c)
{
super (c);
int count = c.getItemCount ();
if (count > 0)
{
for (int i = 0; i < count; i++)
add(c.getItem(i), i);
selected = c.getSelectedIndex();
if (selected >= 0)
select( selected );
}
else
selected = -1;
}
示例2: queryAdditionalParameters
import java.awt.Choice; //導入依賴的package包/類
@Override
public void queryAdditionalParameters( final GenericDialog gd )
{
gd.addChoice( "ImgLib2_container_FFTs", BoundingBoxGUI.imgTypes, BoundingBoxGUI.imgTypes[ defaultFFTImgType ] );
gd.addCheckbox( "Save_memory (not keep FFT's on CPU, 2x time & 0.5x memory)", defaultSaveMemory );
saveMem = (Checkbox)gd.getCheckboxes().lastElement();
gd.addChoice( "Type_of_iteration", iterationTypeString, iterationTypeString[ defaultIterationType ] );
it = (Choice)gd.getChoices().lastElement();
gd.addChoice( "Image_weights", weightsString, weightsString[ defaultWeightType ] );
weight = (Choice)gd.getChoices().lastElement();
gd.addChoice( "OSEM_acceleration", osemspeedupChoice, osemspeedupChoice[ defaultOSEMspeedupIndex ] );
gd.addNumericField( "Number_of_iterations", defaultNumIterations, 0 );
gd.addCheckbox( "Debug_mode", defaultDebugMode );
gd.addCheckbox( "Adjust_blending_parameters (if stripes are visible)", defaultAdjustBlending );
gd.addCheckbox( "Use_Tikhonov_regularization", defaultUseTikhonovRegularization );
gd.addNumericField( "Tikhonov_parameter", defaultLambda, 4 );
gd.addChoice( "Compute", blocksChoice, blocksChoice[ defaultBlockSizeIndex ] );
block = (Choice)gd.getChoices().lastElement();
gd.addChoice( "Compute_on", computationOnChoice, computationOnChoice[ defaultComputationTypeIndex ] );
gpu = (Choice)gd.getChoices().lastElement();
gd.addChoice( "PSF_estimation", extractPSFChoice, extractPSFChoice[ defaultExtractPSF ] );
gd.addChoice( "PSF_display", displayPSFChoice, displayPSFChoice[ defaultDisplayPSF ] );
}
示例3: getRoiSource
import java.awt.Choice; //導入依賴的package包/類
private ImagePlus getRoiSource(ImagePlus imp, Choice imageList, Choice optionList)
{
// Get the ROI option
if (optionList.getSelectedItem().equals(OPTION_NONE))
{
// No ROI image
return null;
}
// Find the image in the image list
if (imageList.getSelectedItem().equals(CHANNEL_IMAGE))
{
// Channel image is the source for the ROI
return imp;
}
return WindowManager.getImage(imageList.getSelectedItem());
}
示例4: test
import java.awt.Choice; //導入依賴的package包/類
private static void test(final Point tmp) throws Exception {
Choice choice = new Choice();
for (int i = 1; i < 7; i++) {
choice.add("Long-long-long-long-long text in the item-" + i);
}
Frame frame = new Frame();
try {
frame.setAlwaysOnTop(true);
frame.setLayout(new FlowLayout());
frame.add(choice);
frame.pack();
frameWidth = frame.getWidth();
frame.setSize(frameWidth, SIZE);
frame.setVisible(true);
frame.setLocation(tmp.x, tmp.y);
openPopup(choice);
} finally {
frame.dispose();
}
}
示例5: UI
import java.awt.Choice; //導入依賴的package包/類
private static void UI() {
Frame frame = new Frame("Test frame");
Choice choice = new Choice();
Stream.of(new String[]{"item 1", "item 2", "item 3"}).forEach(choice::add);
frame.add(choice);
frame.setBounds(100, 100, 400, 200);
frame.setVisible(true);
Font font = choice.getFont();
int size = font.getSize();
int height = choice.getBounds().height;
try {
if (height < size) {
throw new RuntimeException("Test failed");
}
} finally {
frame.dispose();
}
}
示例6: removeItemListener
import java.awt.Choice; //導入依賴的package包/類
/**
* Maps {@code Choice.removeItemListener(ItemListener)} through queue
*/
public void removeItemListener(final ItemListener itemListener) {
runMapping(new MapVoidAction("removeItemListener") {
@Override
public void map() {
((Choice) getSource()).removeItemListener(itemListener);
}
});
}
示例7: select
import java.awt.Choice; //導入依賴的package包/類
/**
* Maps {@code Choice.select(int)} through queue
*/
public void select(final int pos) {
runMapping(new MapVoidAction("select") {
@Override
public void map() {
((Choice) getSource()).select(pos);
}
});
}
示例8: setState
import java.awt.Choice; //導入依賴的package包/類
/**
* Maps {@code Choice.select(String)} through queue
*/
public void setState(final String str) {
runMapping(new MapVoidAction("select") {
@Override
public void map() {
((Choice) getSource()).select(str);
}
});
}
示例9: checkComponent
import java.awt.Choice; //導入依賴的package包/類
@Override
public boolean checkComponent(Component comp) {
if (comp instanceof Choice) {
if (((Choice) comp).getSelectedItem() != null) {
return (comparator.equals(((Choice) comp).getSelectedItem(),
label));
}
}
return false;
}
示例10: DitherControls
import java.awt.Choice; //導入依賴的package包/類
public DitherControls(DitherTest app, int s, int e, DitherMethod type,
boolean vertical) {
applet = app;
setLayout(dcLayout);
add(new Label(vertical ? "Vertical" : "Horizontal"));
add(choice = new Choice());
for (DitherMethod m : DitherMethod.values()) {
choice.addItem(m.toString().substring(0, 1)
+ m.toString().substring(1).toLowerCase());
}
choice.select(type.ordinal());
add(start = new CardinalTextField(Integer.toString(s), 4));
add(end = new CardinalTextField(Integer.toString(e), 4));
}
示例11: DrawControls
import java.awt.Choice; //導入依賴的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);
}
示例12: itemStateChanged
import java.awt.Choice; //導入依賴的package包/類
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getSource() instanceof Checkbox) {
target.setForeground(((Component) e.getSource()).getForeground());
} else if (e.getSource() instanceof Choice) {
String choice = (String) e.getItem();
if (choice.equals("Lines")) {
target.setDrawMode(DrawPanel.LINES);
} else if (choice.equals("Points")) {
target.setDrawMode(DrawPanel.POINTS);
}
}
}
示例13: CardTest
import java.awt.Choice; //導入依賴的package包/類
@SuppressWarnings("LeakingThisInConstructor")
public CardTest() {
setLayout(new BorderLayout());
add("Center", cards = new CardPanel(this));
Panel p = new Panel();
p.setLayout(new FlowLayout());
add("South", p);
Button b = new Button("first");
b.addActionListener(this);
p.add(b);
b = new Button("next");
b.addActionListener(this);
p.add(b);
b = new Button("previous");
b.addActionListener(this);
p.add(b);
b = new Button("last");
b.addActionListener(this);
p.add(b);
Choice c = new Choice();
c.addItem("one");
c.addItem("two");
c.addItem("three");
c.addItem("four");
c.addItem("five");
c.addItem("six");
c.addItemListener(this);
p.add(c);
}
示例14: getDump
import java.awt.Choice; //導入依賴的package包/類
/**
* Returns information about component.
*/
@Override
public Hashtable<String, Object> getDump() {
Hashtable<String, Object> result = super.getDump();
if (((Choice) getSource()).getSelectedItem() != null) {
result.put(SELECTED_ITEM_DPROP, ((Choice) getSource()).getSelectedItem());
}
String[] items = new String[((Choice) getSource()).getItemCount()];
for (int i = 0; i < ((Choice) getSource()).getItemCount(); i++) {
items[i] = ((Choice) getSource()).getItem(i);
}
addToDump(result, ITEM_PREFIX_DPROP, items);
return result;
}
示例15: add
import java.awt.Choice; //導入依賴的package包/類
/**
* Maps {@code Choice.add(String)} through queue
*/
public void add(final String item) {
runMapping(new MapVoidAction("add") {
@Override
public void map() {
((Choice) getSource()).add(item);
}
});
}