Hallo,kann jemanden mir helfen,wenn ich ein Fenster habe und dies ist nicht Visible ist,trotzt allem KeyEvent abfangen,oder nicht.
Ich will ein Fenster unhide haben,aber über Fenster die KeyEvent einlesen!!
hier ist mein code:
import java.awt.TextArea;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.Frame;
public class HelloWorld extends Frame implements KeyListener{
/**
*
*/
private static final long serialVersionUID = 1L;
/**
*
*/
/**
* @param args
*/
public HelloWorld()
{
this.addKeyListener(this);
TextArea feld=new TextArea();
feld.setBounds(50,50,20,20);
this.add(feld);
feld.addKeyListener(this);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
HelloWorld window= new HelloWorld();
window.setTitle("HelloWorld");
window.setSize(300,300);
window.setResizable(true);
window.setVisible(false);
}
public void keyTyped(KeyEvent arg0) {
// TODO Auto-generated method stub
System.out.println("keyTyped");
}
public void keyPressed(KeyEvent arg0) {
// TODO Auto-generated method stub
System.out.println("keyPressed");
}
public void keyReleased(KeyEvent arg0) {
// TODO Auto-generated method stub
}
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
}
Ich will ein Fenster unhide haben,aber über Fenster die KeyEvent einlesen!!
hier ist mein code:
import java.awt.TextArea;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.Frame;
public class HelloWorld extends Frame implements KeyListener{
/**
*
*/
private static final long serialVersionUID = 1L;
/**
*
*/
/**
* @param args
*/
public HelloWorld()
{
this.addKeyListener(this);
TextArea feld=new TextArea();
feld.setBounds(50,50,20,20);
this.add(feld);
feld.addKeyListener(this);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
HelloWorld window= new HelloWorld();
window.setTitle("HelloWorld");
window.setSize(300,300);
window.setResizable(true);
window.setVisible(false);
}
public void keyTyped(KeyEvent arg0) {
// TODO Auto-generated method stub
System.out.println("keyTyped");
}
public void keyPressed(KeyEvent arg0) {
// TODO Auto-generated method stub
System.out.println("keyPressed");
}
public void keyReleased(KeyEvent arg0) {
// TODO Auto-generated method stub
}
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
}