Ich habe deinen Code ein wenig aufgeräumt. Versuch’s mal hiermit:
import java.awt.event.*;
import javax.swing.*;
public class FullScreenJFrame extends JFrame {
public FullScreenJFrame(String title) {
super(title);
setUndecorated(true);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds(0, 0, screenSize.width, screenSize.height);
addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
FullScreenJFrame.this.setVisible(false);
System.exit(0);
}
}
});
}//End of method FullScreenJFrame
public FullScreenJFrame() {
super("Nachrichtentransfer");
}
public static void main(String[] args) {
Runnable gui = new Runnable() {
public void run() {
FullScreenJFrame frame = new FullScreenJFrame("Plasma");
Plasma plasma = new Plasma();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
plasma.init();
plasma.start();
plasma.setFocusable(false);
plasma.setPreferredSize(new Dimension(400, 0));
frame.add(plasma, BorderLayout.LINE_END);
frame.setVisible(true);
}
};
//GUI must start on EventDispatchThread:
SwingUtilities.invokeLater(gui);
}
@Override
public void paint(Graphics g) {
g.setFont(new Font("Serif", Font.PLAIN, 18));
g.drawString("Zum Beenden bitte ESC drücken...", 10, 50);
}
}//End of class FullScreenJFrame```