H
hagemann.k
hello everybody,
i have 2 big problems. i want to code a screensaver with java a very
simple one, but i don't have so much experience with java. the
programm code is from many sites on the internet. but it doesen't
work. Can you look over this and correct it for me, please. or tell me
how i can fix the problems? please it is very important for me.
import java.awt.*;
import java.awt.event.*;
import java.awt.Graphics.*;
import java.awt.Image.*;
public class bildschirmschoner2 extends Window {
Image bild;
public static void main(String[] args) {
final bildschirmschoner schoner = new
bildschirmschoner();
schoner.setSize(schoner.getToolkit().getScreenSize());
schoner.setVisible(true);
Component cp = schoner.getContentPane();
cp.setFocusable(true);
cp.requestFocusInWindow();
cp.addKeyListener(
new KeyAdapter() {
public void keyPressed(KeyEvent event)
{
schoner.setVisible(false);
schoner.dispose();
System.exit(0);
}
}
);
}
public bildschirmschoner2() {
super(new Frame());
setBackground(Color.black);
}
public void init() {
// Bild laden
bild = getImage(getCodeBase(), "bild.jpg");
}
public void paint(Graphics ausgabe) {
ausgabe.setColor(Color.white);
ausgabe.drawString("Mann eh wasn hhier los warum sieht
man das denn nicht",10,10);
ausgabe.drawImage(bild,20,40,this);
}
}
i have 2 big problems. i want to code a screensaver with java a very
simple one, but i don't have so much experience with java. the
programm code is from many sites on the internet. but it doesen't
work. Can you look over this and correct it for me, please. or tell me
how i can fix the problems? please it is very important for me.
import java.awt.*;
import java.awt.event.*;
import java.awt.Graphics.*;
import java.awt.Image.*;
public class bildschirmschoner2 extends Window {
Image bild;
public static void main(String[] args) {
final bildschirmschoner schoner = new
bildschirmschoner();
schoner.setSize(schoner.getToolkit().getScreenSize());
schoner.setVisible(true);
Component cp = schoner.getContentPane();
cp.setFocusable(true);
cp.requestFocusInWindow();
cp.addKeyListener(
new KeyAdapter() {
public void keyPressed(KeyEvent event)
{
schoner.setVisible(false);
schoner.dispose();
System.exit(0);
}
}
);
}
public bildschirmschoner2() {
super(new Frame());
setBackground(Color.black);
}
public void init() {
// Bild laden
bild = getImage(getCodeBase(), "bild.jpg");
}
public void paint(Graphics ausgabe) {
ausgabe.setColor(Color.white);
ausgabe.drawString("Mann eh wasn hhier los warum sieht
man das denn nicht",10,10);
ausgabe.drawImage(bild,20,40,this);
}
}