28/09/2005, 20:04
|
| | Fecha de Ingreso: junio-2005 Ubicación: Cucuta
Mensajes: 62
Antigüedad: 19 años, 6 meses Puntos: 2 | |
Creo que no me hize entender Creo que no me hize entender pero lo importante es que ya encontre la solucion, muchas gracias por contestar
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.text.JTextComponent;
public class Frame2 extends JFrame implements ActionListener, KeyListener
{
protected JComboBox jComboBox = new JComboBox(new String[]{"Bruno", "GUJ", "OS"});
protected JPanel jPanel = new JPanel();
public Frame2() throws HeadlessException
{
super ( );
this.setDefaultCloseOperation(3);
this.setPreferredSize(new Dimension(640,480));
jPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
jComboBox.setEditable(true);
JTextComponent editor = (JTextComponent)jComboBox.getEditor().getEditorCom ponent();
editor.addKeyListener(this);
/* jComboBox.addActionListener(this);*/
/* jComboBox.addKeyListener(this);*/
jPanel.add(jComboBox);
Container container = this.getContentPane();
container.add(jPanel);
}
public static void main(String[] args)
{
Frame2 fs = new Frame2();
fs.pack();
fs.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
/* System.out.println ( jComboBox.getSelectedItem().toString()); */
}
public void keyPressed(KeyEvent e)
{
}
public void keyReleased(KeyEvent e)
{
System.out.println ("HOLA");
}
}
public void keyTyped(KeyEvent e)
{
/*System.out.println ( jComboBox.getSelectedItem().toString());*/
}
} |