亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? itemchooser.java

?? 共有164個java源程序
?? JAVA
字號:
/* * Copyright (c) 2000 David Flanagan.  All rights reserved. * This code is from the book Java Examples in a Nutshell, 2nd Edition. * It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or implied. * You may study, use, and modify it for any non-commercial purpose. * You may distribute it non-commercially as long as you retain this notice. * For a commercial use license, or to purchase the book (recommended), * visit http://www.davidflanagan.com/javaexamples2. */package com.davidflanagan.examples.gui;import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.event.*;import javax.swing.border.*;import java.util.*;/** * This class is a Swing component that presents a choice to the user.  It * allows the choice to be presented in a JList, in a JComboBox, or with a * bordered group of JRadioButton components.  Additionally, it displays the * name of the choice with a JLabel.  It allows an arbitrary value to be * associated with each possible choice.  Note that this component only allows * one item to be selected at a time.  Multiple selections are not supported. **/public class ItemChooser extends JPanel {    // These fields hold property values for this component    String name;           // The overall name of the choice    String[] labels;       // The text for each choice option    Object[] values;       // Arbitrary values associated with each option    int selection;         // The selected choice    int presentation;      // How the choice is presented    // These are the legal values for the presentation field    public static final int LIST = 1;    public static final int COMBOBOX = 2;    public static final int RADIOBUTTONS = 3;    // These components are used for each of the 3 possible presentations    JList list;                     // One type of presentation    JComboBox combobox;             // Another type of presentation    JRadioButton[] radiobuttons;    // Yet another type    // The list of objects that are interested in our state    ArrayList listeners = new ArrayList();    // The constructor method sets everything up    public ItemChooser(String name, String[] labels, Object[] values,		       int defaultSelection, int presentation)    {	// Copy the constructor arguments to instance fields	this.name = name;	this.labels = labels;	this.values = values;	this.selection = defaultSelection;	this.presentation = presentation;	// If no values were supplied, use the labels	if (values == null) this.values = labels;	// Now create content and event handlers based on presentation type	switch(presentation) {	case LIST: initList(); break;	case COMBOBOX: initComboBox(); break;	case RADIOBUTTONS: initRadioButtons(); break;	}    }    // Initialization for JList presentation    void initList() {	list = new JList(labels);          // Create the list	list.setSelectedIndex(selection);  // Set initial state		// Handle state changes	list.addListSelectionListener(new ListSelectionListener() {		public void valueChanged(ListSelectionEvent e) {		    ItemChooser.this.select(list.getSelectedIndex());		}	    });		// Lay out list and name label vertically	this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // vertical	this.add(new JLabel(name));        // Display choice name	this.add(new JScrollPane(list));   // Add the JList    }        // Initialization for JComboBox presentation    void initComboBox() {	combobox = new JComboBox(labels);         // Create the combo box	combobox.setSelectedIndex(selection);     // Set initial state		// Handle changes to the state	combobox.addItemListener(new ItemListener() {		public void itemStateChanged(ItemEvent e) {		    ItemChooser.this.select(combobox.getSelectedIndex());		}	    });		// Lay out combo box and name label horizontally	this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));	this.add(new JLabel(name));	this.add(combobox);    }        // Initialization for JRadioButton presentation    void initRadioButtons() {	// Create an array of mutually exclusive radio buttons	radiobuttons = new JRadioButton[labels.length];   // the array	ButtonGroup radioButtonGroup = new ButtonGroup(); // used for exclusion	ChangeListener listener = new ChangeListener() {  // A shared listener		public void stateChanged(ChangeEvent e) {		    JRadioButton b = (JRadioButton)e.getSource();		    if (b.isSelected()) {			// If we received this event because a button was			// selected, then loop through the list of buttons to			// figure out the index of the selected one.			for(int i = 0; i < radiobuttons.length; i++) {			    if (radiobuttons[i] == b) {				ItemChooser.this.select(i);				return;			    }			}		    }		}	    };		// Display the choice name in a border around the buttons	this.setBorder(new TitledBorder(new EtchedBorder(), name));	this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));		// Create the buttons, add them to the button group, and specify	// the event listener for each one.	for(int i = 0; i < labels.length; i++) {	    radiobuttons[i] = new JRadioButton(labels[i]);	    if (i == selection) radiobuttons[i].setSelected(true);	    radiobuttons[i].addChangeListener(listener);	    radioButtonGroup.add(radiobuttons[i]);	    this.add(radiobuttons[i]);	}    }        // These simple property accessor methods just return field values    // These are read-only properties.  The values are set by the constructor    // and may not be changed.    public String getName() { return name; }    public int getPresentation() { return presentation; }    public String[] getLabels() { return labels; }    public Object[] getValues() { return values; }        /** Return the index of the selected item */    public int getSelectedIndex() { return selection; }        /** Return the object associated with the selected item */    public Object getSelectedValue() { return values[selection]; }        /**     * Set the selected item by specifying its index.  Calling this     * method changes the on-screen display but does not generate events.     **/    public void setSelectedIndex(int selection) {	switch(presentation) {	case LIST: list.setSelectedIndex(selection); break;	case COMBOBOX: combobox.setSelectedIndex(selection); break;	case RADIOBUTTONS: radiobuttons[selection].setSelected(true); break;	}	this.selection = selection;    }    /**     * This internal method is called when the selection changes.  It stores     * the new selected index, and fires events to any registered listeners.     * The event listeners registered on the JList, JComboBox, or JRadioButtons     * all call this method.     **/    protected void select(int selection) {	this.selection = selection;  // Store the new selected index	if (!listeners.isEmpty()) {  // If there are any listeners registered	    // Create an event object to describe the selection	    ItemChooser.Event e =		new ItemChooser.Event(this, selection, values[selection]);	    // Loop through the listeners using an Iterator	    for(Iterator i = listeners.iterator(); i.hasNext();) {		ItemChooser.Listener l = (ItemChooser.Listener)i.next();		l.itemChosen(e);  // Notify each listener of the selection	    }	}    }    // These methods are for event listener registration and deregistration    public void addItemChooserListener(ItemChooser.Listener l) {	listeners.add(l);    }    public void removeItemChooserListener(ItemChooser.Listener l) {	listeners.remove(l);    }    /**     * This inner class defines the event type generated by ItemChooser objects     * The inner class name is Event, so the full name is ItemChooser.Event     **/    public static class Event extends java.util.EventObject {	int selectedIndex;      // index of the selected item	Object selectedValue;   // the value associated with it	public Event(ItemChooser source,		     int selectedIndex, Object selectedValue) {	    super(source);	    this.selectedIndex = selectedIndex;	    this.selectedValue = selectedValue;	}	public ItemChooser getItemChooser() { return (ItemChooser)getSource();}	public int getSelectedIndex() { return selectedIndex; }	public Object getSelectedValue() { return selectedValue; }    }    /**     * This inner interface must be implemented by any object that wants to be     * notified when the current selection in a ItemChooser component changes.     **/    public interface Listener extends java.util.EventListener {	public void itemChosen(ItemChooser.Event e);    }    /**     * This inner class is a simple demonstration of the ItemChooser component     * It uses command-line arguments as ItemChooser labels and values.     **/    public static class Demo {	public static void main(String[] args) {	    // Create a window, arrange to handle close requests	    final JFrame frame = new JFrame("ItemChooser Demo");	    frame.addWindowListener(new WindowAdapter() {		    public void windowClosing(WindowEvent e) {System.exit(0);}		});	    // A "message line" to display results in	    final JLabel msgline = new JLabel(" ");	    // Create a panel holding three ItemChooser components	    JPanel chooserPanel = new JPanel();	    final ItemChooser c1 = new ItemChooser("Choice #1", args, null, 0,						   ItemChooser.LIST);	    final ItemChooser c2 = new ItemChooser("Choice #2", args, null, 0,						   ItemChooser.COMBOBOX);	    final ItemChooser c3 = new ItemChooser("Choice #3", args, null, 0,						   ItemChooser.RADIOBUTTONS);	    	    // An event listener that displays changes on the message line	    ItemChooser.Listener l = new ItemChooser.Listener() {		    public void itemChosen(ItemChooser.Event e) {			msgline.setText(e.getItemChooser().getName() + ": " +					e.getSelectedIndex() + ": " +					e.getSelectedValue());		    }		};	    c1.addItemChooserListener(l);	    c2.addItemChooserListener(l);	    c3.addItemChooserListener(l);	    // Instead of tracking every change with a ItemChooser.Listener,	    // applications can also just query the current state when	    // they need it.  Here's a button that does that.	    JButton report = new JButton("Report");	    report.addActionListener(new ActionListener() {		    public void actionPerformed(ActionEvent e) {			// Note the use of multi-line italic HTML text			// with the JOptionPane message dialog box.			String msg = "<html><i>" +			  c1.getName() + ": " + c1.getSelectedValue() + "<br>"+			  c2.getName() + ": " + c2.getSelectedValue() + "<br>"+			  c3.getName() + ": " + c3.getSelectedValue() + "</i>";			JOptionPane.showMessageDialog(frame, msg);		    }		});	    // Add the 3 ItemChooser objects, and the Button to the panel	    chooserPanel.add(c1);	    chooserPanel.add(c2);	    chooserPanel.add(c3);	    chooserPanel.add(report);	    // Add the panel and the message line to the window	    Container contentPane = frame.getContentPane();	    contentPane.add(chooserPanel, BorderLayout.CENTER);	    contentPane.add(msgline, BorderLayout.SOUTH);	    	    // Set the window size and pop it up.	    frame.pack();	    frame.show();	}    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产在线国偷精品免费看| 3atv在线一区二区三区| 欧美电影影音先锋| 国产精品二区一区二区aⅴ污介绍| 亚洲欧美日韩中文播放| 国产精一区二区三区| 欧美综合视频在线观看| 久久久久9999亚洲精品| 日韩一区欧美二区| 91美女片黄在线观看| 久久久午夜精品理论片中文字幕| 一二三四区精品视频| 成人综合婷婷国产精品久久| 日韩亚洲国产中文字幕欧美| 亚洲制服丝袜av| 波多野结衣精品在线| 久久先锋影音av| 蜜臀av一级做a爰片久久| 在线亚洲免费视频| 亚洲精品视频免费观看| 91在线观看美女| 国产精品美女久久久久aⅴ| 久久精品二区亚洲w码| 欧美一区二区三区色| 午夜成人免费视频| 欧美在线你懂得| 亚洲一区二区三区四区五区中文 | 激情综合色综合久久| 欧美男男青年gay1069videost | 成人福利视频网站| 中文字幕免费一区| 国产成人aaa| 国产日韩三级在线| 成人av片在线观看| 国产精品久久一卡二卡| 99久久久久久| 一个色综合av| 678五月天丁香亚洲综合网| 视频一区中文字幕国产| 欧美顶级少妇做爰| 精品一区二区三区免费毛片爱| 欧美一级高清片在线观看| 日本在线播放一区二区三区| 欧美一区二区三区在线视频| 蜜桃av一区二区在线观看| 精品国产乱码久久久久久1区2区 | 日本伊人色综合网| 日韩一区二区三区精品视频 | 亚洲国产成人av好男人在线观看| 欧美日韩午夜在线视频| 日韩高清国产一区在线| 久久亚洲精品国产精品紫薇| 成人av电影在线网| 亚洲一卡二卡三卡四卡五卡| 在线不卡一区二区| 国产在线精品免费| 亚洲色图在线播放| 日韩一区二区三区av| 国产一区二区女| 亚洲精品第1页| 欧美一级电影网站| 成人动漫精品一区二区| 亚洲福利一二三区| 久久综合色之久久综合| 91在线视频播放地址| 性做久久久久久| 国产日韩三级在线| 欧美日韩成人综合天天影院 | 国产一区美女在线| 亚洲天堂网中文字| 日韩无一区二区| 99免费精品在线观看| 免费观看一级特黄欧美大片| 国产精品麻豆久久久| 正在播放亚洲一区| fc2成人免费人成在线观看播放| 日韩在线一区二区三区| 最新热久久免费视频| 日韩一级完整毛片| 91福利国产精品| 成人一道本在线| 蜜桃视频免费观看一区| 亚洲国产一区二区视频| 国产精品久久久久久妇女6080| 欧美男生操女生| 日本二三区不卡| 国产成人在线观看免费网站| 亚洲成人三级小说| 综合欧美亚洲日本| 2020国产精品| 欧美一级理论片| 日本黄色一区二区| caoporen国产精品视频| 国产一区二区三区综合| 青青草国产精品亚洲专区无| 亚洲精品一卡二卡| 国产精品福利电影一区二区三区四区| 精品久久一二三区| 欧美日韩精品欧美日韩精品一综合| 国产成人亚洲综合a∨猫咪| 欧美aⅴ一区二区三区视频| 一区二区三区在线播放| 国产精品久久久久毛片软件| 久久亚洲影视婷婷| 久久综合久久综合九色| 日韩美女一区二区三区| 91精品久久久久久久久99蜜臂| 欧美日韩一区二区三区免费看| 99久久综合精品| 99视频精品在线| 91在线视频在线| 91免费看视频| 91在线观看成人| 一道本成人在线| 91日韩精品一区| 91成人国产精品| 欧美色区777第一页| 欧美片在线播放| 日韩精品一区在线观看| 欧美mv日韩mv| 日本一区二区三区四区| 欧美激情在线观看视频免费| 国产精品理伦片| 亚洲欧洲中文日韩久久av乱码| 亚洲视频免费看| 亚洲线精品一区二区三区八戒| 亚洲一级片在线观看| 亚洲v精品v日韩v欧美v专区| 日韩国产在线观看| 激情综合色播五月| 成人在线综合网站| 色综合久久久久综合99| 欧美日韩精品一区二区天天拍小说 | 亚洲国产综合色| 免费av网站大全久久| 国产一区999| 99国产精品视频免费观看| 欧美婷婷六月丁香综合色| 欧美一区日韩一区| 精品国产乱码久久久久久久| 中文字幕制服丝袜成人av| 亚洲成a人片在线不卡一二三区 | 国产成人自拍网| 日本伦理一区二区| 精品美女一区二区| 国产精品久久久久久久裸模| 亚洲综合自拍偷拍| 黄色日韩三级电影| 色欧美片视频在线观看在线视频| 欧美精品三级在线观看| 国产日韩欧美精品一区| 亚洲成人av中文| 国产一区二区精品久久91| 一本高清dvd不卡在线观看| 日韩午夜精品视频| 自拍偷拍欧美激情| 老司机免费视频一区二区| 不卡视频免费播放| 欧美草草影院在线视频| 国产精品久久久久影视| 日本不卡视频在线观看| 99精品视频在线观看| 欧美一区二区福利在线| 亚洲欧洲精品成人久久奇米网| 五月激情丁香一区二区三区| 成人开心网精品视频| 欧美一区二区福利视频| 最新国产成人在线观看| 国产一区欧美一区| 日韩视频在线观看一区二区| 亚洲综合色噜噜狠狠| 岛国精品在线观看| 欧美精品一区二区三区视频| 亚洲第一久久影院| 91久久人澡人人添人人爽欧美| 精品国产乱码久久久久久浪潮| 婷婷国产v国产偷v亚洲高清| 色综合久久中文综合久久97| 欧美激情综合在线| 国产精品一卡二卡在线观看| 欧美一级国产精品| 亚洲成人av资源| 欧美日韩一区二区三区在线 | 久久国产精品72免费观看| 欧美性受xxxx| 亚洲免费色视频| www.欧美.com| 国产精品国产三级国产普通话99| 国产专区综合网| 26uuu亚洲综合色欧美| 老司机精品视频导航| 91精品国产综合久久福利软件 | 国产视频亚洲色图| 黄一区二区三区| 日韩精品中文字幕一区二区三区| 人人狠狠综合久久亚洲| 欧美一区二区成人6969| 久久99精品久久久久久动态图| 日韩一区二区电影在线| 久草精品在线观看|