JWindow
I trying to add an KeyListener to a JWindow but it doesn't seem to work. Although if I chance the JWindow into a JFrame it works fine. How can I get around this problem?
Also is it possible to get a title bar(The things that sit at on the task bar in windows)?
The code I'm using is
import javax.swing.*;
import java.awt.event.*;
public class Main extends JWindow implements KeyListener{
public Main(){
super();
setBounds(10, 10, 500, 500);
TestPane TP = new TestPane();
add(TP);
setVisible(true);
addKeyListener(this);
}
public static void main(String[] arguments) {
Main win = new Main();
}
public void keyPressed(KeyEvent e) {
dispose();
}
public void keyReleased(KeyEvent e){
}
public void keyTyped(KeyEvent e){
}
}
Any help would be much appreciated, thanks.
Lex Man
[940 byte] By [
LexMan82a] at [2007-10-2 10:53:58]

> I trying to add an KeyListener to a JWindow but it
> doesn't seem to work.
indeed, you should add your KeyListener into the JWindow's listener's list (see addKeyListener method)
> Although if I chance the
> JWindow into a JFrame it works fine. How can I get
> around this problem?
DO use JFrames instead of JWindows, unless you HAVE to use AWT and avoid Swing
>
> Also is it possible to get a title bar(The things
> that sit at on the task bar in windows)?
see setTitle() method
>
> The code I'm using is
>
> import javax.swing.*;
> import java.awt.event.*;
>
> public class Main extends JWindow implements
> KeyListener{
>
>public Main(){
> super();
> setBounds(10, 10, 500, 500);
> TestPane TP = new TestPane();
> add(TP);
> setVisible(true);
> addKeyListener(this);
>
>}
>
>public static void main(String[] arguments) {
> Main win = new Main();
>}
>
>public void keyPressed(KeyEvent e) {
> dispose();
>
>}
>
>public void keyReleased(KeyEvent e){
>
>}
>
>public void keyTyped(KeyEvent e){
>
>}
> }
>
> Any help would be much appreciated, thanks.
>
> Lex Man
[url=http://java.sun.com/j2se/1.5.0/docs/api/]THIS[/url] rocks