这个压缩包里的都是超级经典的java例子

源代码在线查看: combobox_cbgetcur.htm

软件大小: 2381 K
上传用户: sinoarts
关键词: java 超级
下载地址: 免注册下载 普通下载 VIP

相关代码

				
				
				
				Getting and Setting the Selected Item in a JComboBox Component (Java Developers Almanac Example)
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				The Java Developers Almanac 1.4
				
				        Order this book from Amazon.
				    
				
				
				
				
				
				
				
				
				
				
				
				
				
								google_ad_client = "pub-6001183370374757";
				google_ad_width = 120;
				google_ad_height = 600;
				google_ad_format = "120x600_as";
				google_ad_channel = "4777242811";
				google_ad_type = "text_image";
				google_color_border = "FFFFFF";
				google_color_bg = "FFFFFF";
				google_color_link = "6666CC";
				google_color_url = "6666CC";
				google_color_text = "000000";
				//-->   
				
				Home
				    >
				    List of Packages
				    >
				
				    
				    javax.swing
				         [141 examples]
				    
				        >
				        JComboBox
				             [12 examples]
				            
				
				  e757. Getting and Setting the Selected Item in a JComboBox Component
				
				
				
				    // Create a read-only combobox
				    String[] items = {"item1", "item2"};
				    JComboBox cb = new JComboBox(items);
				    
				    // Get current value
				    Object obj = cb.getSelectedItem(); // item1
				    
				    // Set a new value
				    cb.setSelectedItem("item2");
				    obj = cb.getSelectedItem();        // item2
				    
				    // If the new value is not in the list of valid items, the call is ignored
				    cb.setSelectedItem("item3");
				    obj = cb.getSelectedItem();        // item2
				    
				    // However, if the combobox is editable, the new value can be any value
				    cb.setEditable(true);
				    cb.setSelectedItem("item3");
				    obj = cb.getSelectedItem();        // item3
				
				
				
				
				             Related Examples
				
				
				
				
				e756. 
				    Creating a JComboBox Component
				
				
				
				e758. 
				    Getting the Items in a JComboBox Component
				
				
				
				e759. 
				    Adding and Removing an Item in a JComboBox Component
				
				
				
				e760. 
				    Selecting an Item in a JComboBox Component with Multiple Keystrokes
				
				
				
				e761. 
				    Determining If the Menu of a JComboBox Component Is Visible
				
				
				
				e762. 
				    Displaying the Menu in a JComboBox Component Using a Keystroke
				
				
				
				e763. 
				    Displaying the Menu in a JComboBox Component Using a Keystroke If the Selected Item Is Not Unique
				
				
				
				e764. 
				    Setting the Number of Visible Items in the Menu of a JComboBox Component
				
				
				
				e765. 
				    Listening for Changes to the Selected Item in a JComboBox Component
				
				
				
				e766. 
				    Listening for Action Events from a JComboBox Component
				
				
				
				e767. 
				    Determining When the Menu of a JComboBox Component Is Displayed
				
				
				
				
				
				
				
				
				        See also: 
				
				    Actions
				  
				
				
				    JButton
				  
				
				
				    JCheckBox
				  
				
				
				    JDesktop and JInternalFrame
				  
				
				
				    JFrame, JWindow, JDialog
				  
				
				
				    JLabel
				  
				
				
				    JList
				  
				
				
				    JProgressBar
				  
				
				
				    JRadioButton
				  
				
				
				    JScrollPane
				  
				
				
				    JSlider
				  
				
				
				    JSpinner
				  
				
				
				    JSplitPane
				  
				
				
				    JTabbedPane
				  
				
				
				    JToolBar
				  
				
				
				    Keystrokes and Input Maps
				  
				
				
				    Layout
				  
				
				
				    Look and Feel
				  
				
				
				    Menus
				  
				
				
				    Progress Monitor
				  
				
				
				    The Screen
				  
				
				
				    Tool Tips
				  
				
				
				    UI Default Values
				  
				
				
				
				
				
				
				
				
				
				© 2002 Addison-Wesley.
				   
				
				
				
				
				
				
				
				
							

相关资源