类java.awt.Choice源码实例Demo

下面列出了怎么用java.awt.Choice的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: openjdk-jdk9   文件: ChoicePopupLocation.java
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();
    }
}
 
源代码2 项目: openjdk-jdk9   文件: ChoiceTest.java
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();
    }
}
 
源代码3 项目: SPIM_Registration   文件: PreDefinedBoundingBox.java
protected void addListeners(
		final GenericDialog gd,
		final Choice choice,
		final Label label1,
		final Label label2 )
{
	choice.addItemListener( new ItemListener()
	{
		@Override
		public void itemStateChanged(ItemEvent e)
		{
			update( spimData, choice, label1, label2 );
		}
	});

	update( spimData, choice, label1, label2 );
}
 
源代码4 项目: MorphoLibJ   文件: DrawTableValuesPlugin.java
private void replaceStrings(Choice choice, String[] strings, String defaultString)
{
    choice.removeAll();
       for (String str : strings) 
       {
           choice.add(str);
       }
       choice.select(defaultString);
}
 
源代码5 项目: dragonwell8_jdk   文件: DrawTest.java
@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);
        }
    }
}
 
源代码6 项目: TencentKona-8   文件: DitherTest.java
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));
}
 
源代码7 项目: TencentKona-8   文件: DrawTest.java
@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);
}
 
源代码8 项目: TencentKona-8   文件: DrawTest.java
@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);
        }
    }
}
 
源代码9 项目: jdk8u60   文件: DitherTest.java
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));
}
 
源代码10 项目: jdk8u60   文件: DrawTest.java
@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);
        }
    }
}
 
源代码11 项目: MorphoLibJ   文件: DrawTableValuesPlugin.java
@Override
public boolean dialogItemChanged(GenericDialog gd, AWTEvent evt) 
{
	if (gd.wasCanceled() || gd.wasOKed()) 
	{
		return true;
	}
	
	@SuppressWarnings({ "unchecked" })
       Vector<Choice> choices = gd.getChoices();
	if (choices == null) 
	{
		IJ.log("empty choices array...");
		return false;
	}
	
	// Change of the data table
       if (evt.getSource() == choices.get(0)) 
	{
		String tableName = ((Choice) evt.getSource()).getSelectedItem();
		Frame tableFrame = WindowManager.getFrame(tableName);
		this.table = ((TextWindow) tableFrame).getTextPanel().getResultsTable();
		
		// Choose current headings
		String[] headings = this.table.getHeadings();		
		replaceStrings(choices.get(1), headings, chooseDefaultHeading(headings, xPosHeaderName));
           replaceStrings(choices.get(2), headings, chooseDefaultHeading(headings, yPosHeaderName));
           replaceStrings(choices.get(3), headings, chooseDefaultHeading(headings, valueHeaderName));
	}
	
	return true;
}
 
源代码12 项目: openjdk-jdk8u   文件: DrawTest.java
@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);
}
 
源代码13 项目: openjdk-jdk8u   文件: DrawTest.java
@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);
        }
    }
}
 
源代码14 项目: SPIM_Registration   文件: WeightedAverageFusion.java
@Override
public void queryAdditionalParameters( final GenericDialog gd )
{
	if ( Fusion.defaultInterpolation >= Fusion.interpolationTypes.length )
		Fusion.defaultInterpolation = Fusion.interpolationTypes.length - 1;
	
	if ( this.getFusionType() == WeightedAvgFusionType.FUSEDATA )
	{
		int maxViews = 0;
		
		for ( final TimePoint t : timepointsToProcess )
			for ( final Channel c : channelsToProcess )
				maxViews = Math.max( maxViews, FusionHelper.assembleInputData( spimData, t, c, viewIdsToProcess ).size() );
		
		// any choice but all views
		final String[] views = new String[ maxViews ];
		
		views[ 0 ] = "All";
		
		for ( int i = 1; i < views.length; ++i )
			views[ i ] = "" + i;
		
		if ( defaultNumParalellViewsIndex < 0 || defaultNumParalellViewsIndex >= views.length )
			defaultNumParalellViewsIndex = 0;
		
		gd.addChoice( "Process_views_in_paralell", views, views[ defaultNumParalellViewsIndex ] );
		this.sequentialViews = (Choice)gd.getChoices().lastElement();
	}
	
	if ( this.getFusionType() == WeightedAvgFusionType.FUSEDATA )
	{
		gd.addCheckbox( "Blend images smoothly", Fusion.defaultUseBlending );
		gd.addCheckbox( "Content-based fusion", Fusion.defaultUseContentBased );
	}
	gd.addChoice( "Interpolation", Fusion.interpolationTypes, Fusion.interpolationTypes[ Fusion.defaultInterpolation ] );
}
 
源代码15 项目: netbeans   文件: ChoiceBeanInfo.java
/** @return Propertydescriptors */
@Override
protected PropertyDescriptor[] createPDs() throws IntrospectionException {
    return new PropertyDescriptor[] {
        new PropertyDescriptor("selectedObjects", Choice.class, "getSelectedObjects", null), // NOI18N
        new PropertyDescriptor("selectedIndex", Choice.class, "getSelectedIndex", null), // NOI18N
        new PropertyDescriptor("itemCount", Choice.class, "getItemCount", null), // NOI18N
        new PropertyDescriptor("item", Choice.class, "getItem", null), // NOI18N
        new PropertyDescriptor("selectedItem", Choice.class, "getSelectedItem", null), // NOI18N
    };
}
 
源代码16 项目: Websocket-Smart-Card-Signer   文件: SignUI.java
private void updateComboBox(Choice certificateComboBox){
    certificateComboBox.removeAll();
    certificateComboBox.addItem("Loading Certificates...");
    certificateComboBox.select(0);
   
    ArrayList<CertificateData> certList = new ArrayList<CertificateData>();
    try {
        certList = signEngine.loadSmartCardCertificateList(readAllCertificates).certificateList;
    } catch (Exception e) {
        e.printStackTrace();
        SignUtils.playBeeps(1);
        JOptionPane.showMessageDialog(null, "ERROR LOADING CERTIFICATES:\n"+e.getMessage(), "ERROR", JOptionPane.ERROR_MESSAGE);
    }
    
    certificateComboBox.removeAll();
    certificateComboBox.addItem("--Select Certificate--");
    for(int i=0;i<certList.size();i++)
        certificateComboBox.addItem(certList.get(i).id);
    
    if(certificateComboBox.getItemCount()==1){
        certificateComboBox.removeAll();
        certificateComboBox.addItem("--No Certificates Available!--");
        SignUtils.playBeeps(2);
    }
    else{
        if(certificateComboBox.getItemCount()==2){
            certificateComboBox.remove(0);
        }
        SignUtils.playBeeps(1);
    }
}
 
源代码17 项目: openjdk-jdk8u-backup   文件: DitherTest.java
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));
}
 
源代码18 项目: openjdk-jdk8u-backup   文件: DrawTest.java
@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);
}
 
源代码19 项目: openjdk-jdk8u-backup   文件: DrawTest.java
@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);
        }
    }
}
 
源代码20 项目: jdk8u-dev-jdk   文件: DitherTest.java
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));
}
 
源代码21 项目: openjdk-jdk9   文件: DrawTest.java
@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);
        }
    }
}
 
源代码22 项目: jdk8u-dev-jdk   文件: DrawTest.java
@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);
}
 
源代码23 项目: openjdk-jdk9   文件: ChoiceOperator.java
/**
 * 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;
}
 
源代码24 项目: openjdk-jdk9   文件: ChoiceOperator.java
/**
 * 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);
        }
    });
}
 
源代码25 项目: openjdk-jdk9   文件: ChoiceOperator.java
/**
 * Maps {@code Choice.addItemListener(ItemListener)} through queue
 */
public void addItemListener(final ItemListener itemListener) {
    runMapping(new MapVoidAction("addItemListener") {
        @Override
        public void map() {
            ((Choice) getSource()).addItemListener(itemListener);
        }
    });
}
 
源代码26 项目: openjdk-jdk9   文件: ChoiceOperator.java
/**
 * Maps {@code Choice.getItem(int)} through queue
 */
public String getItem(final int index) {
    return (runMapping(new MapAction<String>("getItem") {
        @Override
        public String map() {
            return ((Choice) getSource()).getItem(index);
        }
    }));
}
 
源代码27 项目: openjdk-jdk9   文件: ChoiceOperator.java
/**
 * Maps {@code Choice.getItemCount()} through queue
 */
public int getItemCount() {
    return (runMapping(new MapIntegerAction("getItemCount") {
        @Override
        public int map() {
            return ((Choice) getSource()).getItemCount();
        }
    }));
}
 
源代码28 项目: openjdk-jdk9   文件: ChoiceOperator.java
/**
 * Maps {@code Choice.getSelectedIndex()} through queue
 */
public int getSelectedIndex() {
    return (runMapping(new MapIntegerAction("getSelectedIndex") {
        @Override
        public int map() {
            return ((Choice) getSource()).getSelectedIndex();
        }
    }));
}
 
源代码29 项目: openjdk-jdk9   文件: ChoiceOperator.java
/**
 * Maps {@code Choice.getSelectedItem()} through queue
 */
public String getSelectedItem() {
    return (runMapping(new MapAction<String>("getSelectedItem") {
        @Override
        public String map() {
            return ((Choice) getSource()).getSelectedItem();
        }
    }));
}
 
源代码30 项目: MesquiteCore   文件: BasicTreeConsenser.java
public boolean queryOptions() {
	MesquiteInteger buttonPressed = new MesquiteInteger(1);
	ExtensibleDialog dialog = new ExtensibleDialog(containerOfModule(), getName() + " Options",buttonPressed);  //MesquiteTrunk.mesquiteTrunk.containerOfModule()
	dialog.addLabel(getName() + " Options");
	String helpString = "Please choose the options for consensus trees. ";

	dialog.appendToHelpString(helpString);

	queryOptionsSetup(dialog);

	
	String[] rootingStrings = {"As specified in first tree", "Rooted", "Unrooted"};
	Choice rootingChoice  = dialog.addPopUpMenu("Treat trees as rooted or unrooted:", rootingStrings, 0);


	//TextArea PAUPOptionsField = queryFilesDialog.addTextArea(PAUPOptions, 20);

	dialog.completeAndShowDialog(true);
	if (buttonPressed.getValue()==0)  {
		queryOptionsProcess(dialog);
		int choiceValue = rootingChoice.getSelectedIndex();
		if (choiceValue>=0)
			rooting = choiceValue;
		storePreferences();

	}
	dialog.dispose();
	return (buttonPressed.getValue()==0);
}
 
 类所在包
 类方法
 同包方法