Java Code Examples for java.awt.Choice#add()

The following examples show how to use java.awt.Choice#add() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChoicePopupLocation.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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();
    }
}
 
Example 2
Source File: DrawTableValuesPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void replaceStrings(Choice choice, String[] strings, String defaultString)
{
    choice.removeAll();
       for (String str : strings) 
       {
           choice.add(str);
       }
       choice.select(defaultString);
}
 
Example 3
Source File: Find.java    From pdfxtk with Apache License 2.0 5 votes vote down vote up
private Choice newSortChoice(String[] labels) {
  Choice result = new Choice();
  result.add(labels[Field.NOP]);
  for(int i = Field.ASCENDING; i <= Field.CUSTOM; i++)
    result.add(labels[i]);
  return result;
}
 
Example 4
Source File: PrintfApplet.java    From KEEL with GNU General Public License v3.0 4 votes vote down vote up
private void initInputPanel(Panel p) {
   GridBagConstraints gbc=
     new GridBagConstraints();
   p.setLayout(new GridBagLayout());
   gbc.weightx=100;
   gbc.weighty=100;
   gbc.gridwidth=1;
   gbc.gridheight=1;
   gbc.fill=GridBagConstraints.HORIZONTAL;
   gbc.anchor=GridBagConstraints.WEST;

   gbc.gridx=0;
   gbc.gridy=0;
   Label typeLabel=new Label("Type");
   p.add(typeLabel,gbc);
   gbc.gridx=1;
   gbc.gridwidth=GridBagConstraints.REMAINDER;
   Label valueLabel=new Label("Value");
   p.add(valueLabel,gbc);

   gbc.gridx=0;
   gbc.gridy=1;
   Choice type=new Choice();
   type.add("Byte");
   type.add("Short");
   type.add("Character");
   type.add("Integer");
   type.add("Long");
   type.add("Float");
   type.add("Double");
   type.add("String");
   type.add("Object");
   type.select("Float");
   type.addItemListener(new TypeChoiceCommand());
   p.add(type,gbc);
   gbc.gridx=1;
   gbc.gridwidth=GridBagConstraints.REMAINDER;
   value=new ValueChoice();
   p.add(value,gbc);

   gbc.gridx=0;
   gbc.gridy=2;
   gbc.gridwidth=1;
   gbc.fill=GridBagConstraints.NONE;
   Button reset=new Button("Reset");
   reset.addActionListener(new ResetCommand());
   p.add(reset,gbc);
   gbc.gridx=1;
   gbc.gridwidth=GridBagConstraints.REMAINDER;
   Button position=new Button("Add");
   position.addActionListener(new AddCommand());
   p.add(position,gbc);

gbc.gridx=0;
gbc.gridy=3;
   gbc.gridwidth=1;
   gbc.gridheight=GridBagConstraints.REMAINDER;
   gbc.fill=GridBagConstraints.HORIZONTAL;
   Label format = new Label("Control String");
   p.add(format,gbc);
gbc.gridx=1;
   TextField formatString = new TextField(40);
   gbc.gridwidth=GridBagConstraints.REMAINDER;
   formatString.addTextListener(new FormatCommand());
   p.add(formatString,gbc);
 }
 
Example 5
Source File: LabelToValuePlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean dialogItemChanged(GenericDialog gd, AWTEvent evt) 
{
	if (gd.wasCanceled() || gd.wasOKed()) 
	{
		return true;
	}
	
	@SuppressWarnings("rawtypes")
	Vector 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 heading
		String[] headings = this.table.getHeadings();
		String defaultHeading = headings[0];
		if (defaultHeading.equals("Label") && headings.length > 1) 
		{
			defaultHeading = headings[1];
		}
		
		Choice headingChoice = (Choice) choices.get(1);
		headingChoice.removeAll();
		for (String heading : headings) 
		{
			headingChoice.add(heading);
		}
		headingChoice.select(defaultHeading);

		changeColumnHeader(defaultHeading);
	}
	
	// Change of the column heading
	if (evt.getSource() == choices.get(1)) 
	{
		String headerName = ((Choice) evt.getSource()).getSelectedItem();
           changeColumnHeader(headerName);
	}
	
	return true;
}
 
Example 6
Source File: Find.java    From pdfxtk with Apache License 2.0 4 votes vote down vote up
private Choice newOpChoice(String[] labels) {
  Choice result = new Choice();
  for(int i = Field.NOP; i <= Field.NOT_EQUALS; i++)
    result.add(labels[i]);
  return result;
}