Java 8 Choice - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Choice class.

This code example shows how to use the following methods:addItem, addItemListener
 
        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);
    } 
 
    @Override 
    public void itemStateChanged(ItemEvent e) {
        ((CardLayout) cards.getLayout()).show(cards,
                (String) (e.getItem()));
6
CodeRank
This code example shows how to use the following methods:addItem, addItemListener, setBackground
This code example shows how to use the following methods:add
      _valueText       = new TextField("" ) ;
      _valueText.setBackground( Color.blue ) ;
      _valueText.setForeground( Color.yellow ) ;
      _messageText     = new TextField("") ;
      _messageText.setForeground(Color.red);
      _typeChoice      = new Choice() ;
      _typeChoice.add( "TimeTicks" ) ;
      _typeChoice.add( "OctetString" ) ;
      _typeChoice.add( "Integer" ) ;
      _typeChoice.add( "IpNumber" ) ;
      _typeChoice.add( "OID" ) ;
      _outputText    = new TextArea( 15 , 100 ) ;
      _outputText.setFont( new Font("Monospaced" , Font.BOLD , 12 ) ) ;
      _nextButton    = new Button( "Next" ) ;
      _getButton     = new Button( "Get" ) ;
      _clearButton    = new Button( "Clear" ) ;
      _walkButton     = new Button( "Walk" ) ;
      _stopButton     = new Button( "Stop" ) ;
      _resetButton     = new Button( "Reset OID" ) ;
      _systemButton     = new Button( "System" ) ;
5
CodeRank
This code example shows how to use the following methods:getSelectedIndex, select
 
  public void itemStateChanged(ItemEvent e) {
    final Object src = e.getSource();
    final int zIndex = zChoice.getSelectedIndex();
    final int cIndex = cChoice.getSelectedIndex();
    final int tIndex = tChoice.getSelectedIndex();
    if (src == zChoice) {
      if (zIndex == cIndex) cChoice.select(firstAvailable(zIndex, tIndex));
      else if (zIndex == tIndex) tChoice.select(firstAvailable(zIndex, cIndex));
    } 
    else if (src == cChoice) {
      if (cIndex == zIndex) zChoice.select(firstAvailable(cIndex, tIndex));
      else if (cIndex == tIndex) tChoice.select(firstAvailable(zIndex, cIndex));
    } 
    else if (src == tChoice) {
      if (tIndex == zIndex) zChoice.select(firstAvailable(cIndex, tIndex));
      else if (tIndex == cIndex) cChoice.select(firstAvailable(zIndex, tIndex));
    } 
  } 
 
5
CodeRank
This code example shows how to use the following methods:addItem
			c.addItem("200");
			c.addItem("400");
		cs[numChoices++] = c;
 
		add(new Label("Option 2"));
		add(c = new Choice());
			c.addItem("0");
			c.addItem("100");
			c.addItem("200");
			c.addItem("400");
		cs[numChoices++] = c;
 
		Panel p = new Panel();
		p.setBackground(Color.pink);
		p.add(new Label("Total:"));
		p.add(resultField = new Label("000000"));
		add(p);
 
		sendButton = new Button("Send it");
		add(sendButton);						// connect Button into Applet
5
CodeRank
This code example shows how to use the following methods:dispatchEvent
    @Override 
    protected void fireItemStateChanged(ItemEvent e) {
        super.fireItemStateChanged(e);
        if (e.getStateChange() == ItemEvent.SELECTED) {
            peer.peerSelect(getSelectedIndex());
            awtComponent.dispatchEvent(SwingToolkit.convertEvent(e, awtComponent));
        } 
    } 
 
    /** 
     * Pass an event onto the AWT component. 
     * 
     * @see java.awt.Component#processEvent(java.awt.AWTEvent) 
     */ 
    protected final void processEvent(AWTEvent event) {
        awtComponent.dispatchEvent(SwingToolkit.convertEvent(event, awtComponent));
    } 
 
    public final void processAWTEvent(AWTEvent event) {
        super.processEvent(event);
4
CodeRank
This code example shows how to use the following methods:setLocation
	   width = getSize().width;
      height = getSize().height;
      setBackground( Color.black );
      setFont(new Font("Helvetica", Font.BOLD, 36));
      //Drop Down List 
      choice = new Choice();
      choice.setLocation(50, 80);
        
      //Download Button 
      downloadButton = new Button("Download");
      add(downloadButton);
      downloadButton.addActionListener(this); 
       
      crawlHasFinished = false;
      teamHasBeenClickedOn = false;
      showTeamStatsClicked = false;
       
      //ShowTeamStats Button 
      showTeamStats = new Button("Show Team Stats");
      add(showTeamStats);
4
CodeRank
This code example shows how to use the following methods:getSelectedItem
		public void actionPerformed(ActionEvent e) { 
			URL destURL = null; 
			try { 
				destURL = new URL("http://www.fedex.com/cgi-bin/track_it?" + 
				"&kurrent_airbill=" + numField.getText() + "|" + 
					destChooser.getSelectedItem() + "|" + shipDate + 
					// following boilerplate seems needed 
					"&language=english&cntry_code=us&state=0"); 
			} catch (MalformedURLException err) { 
				System.err.println("Error!\n" + err); 
				showStatus("Error, look in Java Console for details!"); 
			} 
			// debug... 
			System.out.println("URL = " + destURL); 
 
			// "And then a miracle occurs..." 
			FedexTrack.this.getAppletContext().showDocument(destURL); 
		} 
	}; 
 
3
CodeRank
This code example shows how to use the following methods:getSelectedIndex, select
axis0 = i;
			int[] axes = { axis0, axis1 };
			axisHash.put(activeImpID, axes.clone());
			updateDirections(); 
		} else if (source.equals(axis1Choice)) {
			int i = axis1Choice.getSelectedIndex();
			if (i == axis0Choice.getSelectedIndex()) {
				axis1Choice.select(axis1);
				IJ.error("Both axes cannot indicate the same direction"); 
				return; 
			} 
			axis1 = i;
			int[] axes = { axis0, axis1 };
			axisHash.put(activeImpID, axes.clone());
			updateDirections(); 
		} else if (source.equals(reflect0)) {
			isReflected0 = reflect0.getState();
			boolean[] reflectors = { isReflected0, isReflected1 };
			reflectHash.put(activeImpID, reflectors.clone());
4
CodeRank
See Code Examples for Java 8 Choice Methods: