當前位置: 首頁>>代碼示例>>Java>>正文


Java Choice.addItemListener方法代碼示例

本文整理匯總了Java中java.awt.Choice.addItemListener方法的典型用法代碼示例。如果您正苦於以下問題:Java Choice.addItemListener方法的具體用法?Java Choice.addItemListener怎麽用?Java Choice.addItemListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.Choice的用法示例。


在下文中一共展示了Choice.addItemListener方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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);
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:35,代碼來源:DrawTest.java

示例2: 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);
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:35,代碼來源:CardTest.java

示例3: showDialog

import java.awt.Choice; //導入方法依賴的package包/類
/**
 * Show dialog.
 *
 * @return the image plus
 */
public ImagePlus showDialog(){
	gd = new GenericDialog("Add Image");
	gd.setResizable(true);
	gd.pack();
	String[] source = {"From Image","From File"}; 
	gd.addChoice("Image Source:", source, null);
	addImageChoice();
	
	// automatically update name if a different image is selected
	final Choice im = (Choice) gd.getChoices().get(0);
	im.addItemListener(this);
	
	gd.showDialog();
	if(gd.wasCanceled())
		return null;
	
	if(!fromFile) {
		img = fromImage();
	}
	return img;
}
 
開發者ID:spatialsimulator,項目名稱:XitoSBML,代碼行數:27,代碼來源:ImageDialog.java

示例4: enableChannelChoice

import java.awt.Choice; //導入方法依賴的package包/類
private final void enableChannelChoice(final Choice controller, final Choice target, final int[] nostackIDs)
{
	setRGB(nostackIDs[controller.getSelectedIndex()], target);

	controller.addItemListener(new ItemListener()
	{
		@Override
		public void itemStateChanged(ItemEvent ie)
		{
			setRGB(nostackIDs[controller.getSelectedIndex()], target);
		}
	});
}
 
開發者ID:fiji,項目名稱:Stitching,代碼行數:14,代碼來源:Stitching_2D.java

示例5: enableChannelChoice

import java.awt.Choice; //導入方法依賴的package包/類
private final void enableChannelChoice(final Choice controller, final Choice target, final int[] stackIDs)
{
	setRGB(stackIDs[controller.getSelectedIndex()], target);

	controller.addItemListener(new ItemListener()
	{
		@Override
		public void itemStateChanged(ItemEvent ie)
		{
			setRGB(stackIDs[controller.getSelectedIndex()], target);
		}
	});
}
 
開發者ID:fiji,項目名稱:Stitching,代碼行數:14,代碼來源:Stitching_3D.java

示例6: addListeners

import java.awt.Choice; //導入方法依賴的package包/類
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 );
}
 
開發者ID:fiji,項目名稱:SPIM_Registration,代碼行數:18,代碼來源:PreDefinedBoundingBox.java

示例7: initComponents

import java.awt.Choice; //導入方法依賴的package包/類
private void initComponents() {
	
	setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	setBounds(100, 100, 439, 337);
	contentPane = new JPanel();
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	setContentPane(contentPane);
	contentPane.setLayout(null);
	
	txtUsuario = new JTextField();
	txtUsuario.setFont(new Font("Tahoma", Font.BOLD, 11));
	txtUsuario.setEditable(false);
	txtUsuario.setBounds(16, 36, 314, 23);
	contentPane.add(txtUsuario);
	txtUsuario.setColumns(10);
	
	JLabel lblUsuario = new JLabel("Usuario");
	lblUsuario.setBounds(16, 21, 61, 14);
	contentPane.add(lblUsuario);
	
	txtCodigo = new JTextField();
	txtCodigo.setFont(new Font("Tahoma", Font.BOLD, 11));
	txtCodigo.setEditable(false);
	txtCodigo.setBounds(16, 146, 314, 23);
	contentPane.add(txtCodigo);
	txtCodigo.setColumns(10);
	
	lblCodigo = new JLabel("Codigo ");
	lblCodigo.setBounds(16, 128, 126, 14);
	contentPane.add(lblCodigo);	
	
	lblfecha_prestDePrestamo = new JLabel("Fecha de pr\u00E9stamo");
	lblfecha_prestDePrestamo.setBounds(16, 193, 148, 14);
	contentPane.add(lblfecha_prestDePrestamo);
	
	btnBuscarCodigo = new JButton("...");
	btnBuscarCodigo.setBounds(346, 146, 61, 23);
	contentPane.add(btnBuscarCodigo);
	btnBuscarCodigo.setEnabled(false);
	btnBuscarCodigo.addActionListener(this);
	
	btnBuscarUsuario = new JButton("...");
	btnBuscarUsuario.setBounds(346, 35, 61, 23);
	contentPane.add(btnBuscarUsuario);
	btnBuscarUsuario.addActionListener(this);
	
	tipo = new Choice();
	tipo.setBounds(16, 91, 115, 20);
	tipo.add("Seleccione");
	tipo.add("Libro");
	tipo.add("Revista");
	tipo.add("CDROM");
	tipo.add("Articulo");
	tipo.setEnabled(false);
	tipo.addItemListener(this);
	contentPane.add(tipo);
	
	lblTipo = new JLabel("Tipo");
	lblTipo.setBounds(16, 71, 46, 14);
	contentPane.add(lblTipo);
	
	addWindowListener(this);
	setVisible(true);
	setLocationRelativeTo(null);
}
 
開發者ID:JuandeLS3,項目名稱:Library-app,代碼行數:66,代碼來源:NuevoPrestamo.java

示例8: init

import java.awt.Choice; //導入方法依賴的package包/類
public void init ()
{
  cursorChoice = new Choice();
  cursorChoice.add ("Default");
  cursorChoice.add ("Crosshair");
  cursorChoice.add ("Text");
  cursorChoice.add ("Wait");
  cursorChoice.add ("Southwest Resize");
  cursorChoice.add ("Southeast Resize");
  cursorChoice.add ("Northwest Resize");
  cursorChoice.add ("Northeast Resize");
  cursorChoice.add ("North Resize");
  cursorChoice.add ("South Resize");
  cursorChoice.add ("West Resize");
  cursorChoice.add ("East Resize");
  cursorChoice.add ("Hand");
  cursorChoice.add ("Move");

  cursorChoice.addItemListener(this);

  add (cursorChoice, "North");

  cursorCanvas = new Canvas ()
    {
      public void paint (Graphics g)
      {
        Dimension d = this.getSize();
        g.setColor(Color.white);
        g.fillRect(0, 0, d.width, d.height/2);
        g.setColor(Color.black);
        g.fillRect(0, d.height/2, d.width, d.height/2);
        g.setColor(this.getBackground());
        g.fillRect(d.width/3, d.height/3, d.width/3,
                    d.height/3);
      }
    };

  cursorCanvas.setSize (80,80);

  add (cursorCanvas, "Center");

  Button cb = new Button ("Close");
  cb.addActionListener(new ActionListener () {
      public void actionPerformed (ActionEvent e) {
        dispose();
      }
    });

  add (cb, "South");
  setTitle ("Cursors");
  pack();
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:53,代碼來源:Demo.java

示例9: initInputPanel

import java.awt.Choice; //導入方法依賴的package包/類
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);
 }
 
開發者ID:triguero,項目名稱:Keel3.0,代碼行數:67,代碼來源:PrintfApplet.java

示例10: init

import java.awt.Choice; //導入方法依賴的package包/類
public void init ()
   {
     cursorChoice = new Choice();
     cursorChoice.add ("Default");
     cursorChoice.add ("Crosshair");
     cursorChoice.add ("Text");
     cursorChoice.add ("Wait");
     cursorChoice.add ("Southwest Resize");
     cursorChoice.add ("Southeast Resize");
     cursorChoice.add ("Northwest Resize");
     cursorChoice.add ("Northeast Resize");
     cursorChoice.add ("North Resize");
     cursorChoice.add ("South Resize");
     cursorChoice.add ("West Resize");
     cursorChoice.add ("East Resize");
     cursorChoice.add ("Hand");
     cursorChoice.add ("Move");
     
     cursorChoice.addItemListener(this);
     
     add (cursorChoice, "North");
     
     cursorCanvas = new Canvas () 
{ 
  public void paint (Graphics g) 
  {
    Dimension d = this.getSize();
    g.setColor(Color.white);
    g.fillRect(0, 0, d.width, d.height/2);
    g.setColor(Color.black);
    g.fillRect(0, d.height/2, d.width, d.height/2);
    g.setColor(this.getBackground());
    g.fillRect(d.width/3, d.height/3, d.width/3,
		d.height/3);
  }
};
     
     cursorCanvas.setSize (80,80);
     
     add (cursorCanvas, "Center");
     
     Button cb = new Button ("Close");
     cb.addActionListener(new ActionListener () {
  public void actionPerformed (ActionEvent e) {
    dispose();
  }
});
     
     add (cb, "South");
     setTitle ("Cursors");
     pack();
   }
 
開發者ID:nmldiegues,項目名稱:jvm-stm,代碼行數:53,代碼來源:Demo.java

示例11: main

import java.awt.Choice; //導入方法依賴的package包/類
public static void main(String[] args) {
  String s = "Java Tips";
  final int size = 64;
  if (args.length > 0)
    s = args[0];

  Panel controls = new Panel();
  final Choice choice = new Choice();
  GraphicsEnvironment ge = GraphicsEnvironment
      .getLocalGraphicsEnvironment();
  Font[] allFonts = ge.getAllFonts();
  for (int i = 0; i < allFonts.length; i++)
    choice.addItem(allFonts[i].getName());
  Font defaultFont = new Font(allFonts[0].getName(), Font.PLAIN, size);

  final TextBouncer bouncer = new TextBouncer(s, defaultFont);
  Frame f = new AnimationFrame(bouncer);
  f.setFont(new Font("Serif", Font.PLAIN, 12));
  controls.add(bouncer.createCheckbox("Antialiasing",
      TextBouncer.ANTIALIASING));
  controls.add(bouncer.createCheckbox("Gradient", TextBouncer.GRADIENT));
  controls.add(bouncer.createCheckbox("Shear", TextBouncer.SHEAR));
  controls.add(bouncer.createCheckbox("Rotate", TextBouncer.ROTATE));
  controls.add(bouncer.createCheckbox("Axes", TextBouncer.AXES));

  Panel fontControls = new Panel();
  choice.addItemListener(new ItemListener() {
  	@Override
    	public void itemStateChanged(ItemEvent ie) {
      Font font = new Font(choice.getSelectedItem(), Font.PLAIN, size);
      bouncer.setFont(font);
    }
  });
  fontControls.add(choice);

  Panel allControls = new Panel(new GridLayout(2, 1));
  allControls.add(controls);
  allControls.add(fontControls);
  f.add(allControls, BorderLayout.NORTH);
      f.setSize(300,300);
  f.setVisible(true);
}
 
開發者ID:vlabatut,項目名稱:totalboumboum,代碼行數:43,代碼來源:TextBouncer.java

示例12: addInputSourceToDialog

import java.awt.Choice; //導入方法依賴的package包/類
/**
 * Add a list of input sources to the generic dialog. The choice field will be named inputName. If the file input
 * option
 * is true then a field will be added name 'Input_file'.
 * 
 * @param gd
 * @param inputName
 * @param inputOption
 *            The option to select by default
 * @param source
 * @param fileInput
 */
@SuppressWarnings("unused")
public static void addInputSourceToDialog(final ExtendedGenericDialog gd, String inputName, String inputOption,
		ArrayList<String> source, boolean fileInput)
{
	String[] options = source.toArray(new String[source.size()]);
	// Find the option
	inputOption = removeFormatting(inputOption);

	int optionIndex = 0;
	for (int i = 0; i < options.length; i++)
	{
		String name = removeFormatting(options[i]);
		if (name.equals(inputOption))
		{
			optionIndex = i;
			break;
		}
	}
	final Choice c = gd.addAndGetChoice(inputName, options, options[optionIndex]);
	if (fileInput)
	{
		final TextField tf = gd.addFilenameField("Input_file", inputFilename);
		final JButton b = gd.getLastOptionButton();

		// Add a listener to the choice to enable the file input field.
		// Currently we hide the filename field and pack the dialog. 
		// We may wish to just disable the fields and leave them there.
		// This could be a user configured option in a global GDSC settings class.
		if (Utils.isShowGenericDialog())
		{
			final Label l = gd.getLastLabel();
			final Panel p = gd.getLastPanel();
			ItemListener listener = new ItemListener()
			{
				public void itemStateChanged(ItemEvent e)
				{
					boolean enable = INPUT_FILE.equals(c.getSelectedItem());
					if (enable != l.isVisible())
					{
						l.setVisible(enable);
						p.setVisible(enable);
						//tf.setVisible(enable);
						//b.setVisible(enable);
						gd.pack();
					}
				}
			};

			// Run once to set up
			listener.itemStateChanged(null);

			c.addItemListener(listener);
		}
	}
}
 
開發者ID:aherbert,項目名稱:GDSC-SMLM,代碼行數:68,代碼來源:ResultsManager.java

示例13: createFrame

import java.awt.Choice; //導入方法依賴的package包/類
@SuppressWarnings({ "unchecked", "rawtypes" })
private void createFrame()
{
	Panel mainPanel = new Panel();
	add(mainPanel);

	imageChoice = new Choice();
	mainPanel.add(createChoicePanel(imageChoice, null, null, "Image"));
	imageChoice.addItemListener(this);

	synchroniseButton = new JToggleButton("Synchronise");
	synchroniseButton.addItemListener(this);
	
	helpButton = new JButton("Help");
	helpButton.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent e) {
			String macro = "run('URL...', 'url="+gdsc.help.URL.UTILITY+"');";
			new MacroRunner(macro);
		}
	});
	
	JPanel buttonPanel = new JPanel();
	FlowLayout l = new FlowLayout();
	l.setVgap(0);
	buttonPanel.setLayout(l);
	buttonPanel.add(synchroniseButton, BorderLayout.CENTER);
	buttonPanel.add(helpButton, BorderLayout.CENTER);
	
	mainPanel.add(buttonPanel);
	
	mainPanel.add(createLabelPanel("Images to sync:"));

	listModel = new DefaultListModel();
	childList = new JList(listModel);
	childList.setVisibleRowCount(15);
	JScrollPane scrollPane = new JScrollPane(childList);
	mainPanel.add(scrollPane);
	childList.addListSelectionListener(this);

	GridBagLayout mainGrid = new GridBagLayout();
	int y = 0;
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0;
	c.fill = GridBagConstraints.BOTH;
	c.anchor = GridBagConstraints.WEST;
	c.gridwidth = 1;
	c.insets = new Insets(2, 2, 2, 2);

	for (Component comp : mainPanel.getComponents())
	{
		c.gridy = y++;
		mainGrid.setConstraints(comp, c);
	}

	mainPanel.setLayout(mainGrid);
}
 
開發者ID:aherbert,項目名稱:GDSC,代碼行數:58,代碼來源:Stack_Synchroniser.java


注:本文中的java.awt.Choice.addItemListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。