JComboBox 打印 ASCII码



import   java.awt.*; 
import   javax.swing.*; 
import   java.awt.event.*; 

public   class   JComboBoxDemo   extends   JFrame 

private   JComboBox   jcb; 
private   String   names[]={ "1 ", "2 ", "3 "}; 
public   JComboBoxDemo() 

super( "JComboBox   Test "); 
this.setLayout(new   FlowLayout()); 

jcb=new   JComboBox(names); 
jcb.setMaximumRowCount(3); 

        jcb.addKeyListener(new   KeyListener() 
        { 
        public   void   keyPressed(KeyEvent   event){ 
int   keyCode   =   event.getKeyCode(); 
System.out.println( "+++++++++++++++++++keyCode++++++++++++++++++++ "); 
System.out.println( "+++++++++++++++ "+keyCode+ "++++++++++++++++++ "); 
if(keyCode   ==   KeyEvent.VK_ENTER){ 
              System.out.println( "+++++++++++++++++++enter!!!++++++++++++++++++++ "); 


public   void   keyReleased(KeyEvent   event){ 

public   void   keyTyped(KeyEvent   event)   { 

}); 

this.add(jcb); 
setSize(350,200); 
setVisible(true); 

public   static   void   main(String   args[]) 

JComboBoxDemo   app=new   JComboBoxDemo(); 
app.addWindowListener(new   WindowAdapter(){ 
public   void   windowClosing(WindowEvent   e){ 
System.exit(0); 

}); 

}

你可能感兴趣的:(String,Class,import)