G
Guest
Gast
hi,
kann mir jemand sagen wieso JFrame.createImage(int width, int height) hier null zurückliefert?
kann mir jemand sagen wieso JFrame.createImage(int width, int height) hier null zurückliefert?
Code:
import javax.swing.*;
import java.awt.*;
public class DoppelPufferung extends JFrame {
Graphics graphics;
Image image;
protected DoppelPufferung()
{
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(800, 600);
if (GraphicsEnvironment.isHeadless())
System.out.println("head");
this.image = this.createImage(800, 600);
if (this.image != null)
{
System.out.println("test");
graphics = image.getGraphics();
graphics.setColor(new Color(255, 255, 255));
graphics.drawString("hallo", 0, 0);
}
else
{
System.out.println("image == null");
}
}
public void paint(Graphics g)
{
super.paint(g);
g.drawImage(this.image, 0, 0, this);
}
public static void main(String[] args) {
DoppelPufferung dp = new DoppelPufferung();
dp.setVisible(true);
}
}