Guten Tag. Ich stehe vor folgendem Problem. Diese Methode zeichnet mir etwas wie ich es möchte. Diesem Fall ein Viereck mit Kreuz in der Mitte.
Aber wie bekomme ich es hin das die Methode mir ein Bild zeichnet? Ich hab schon eine ganze weile mit der drawImage() Methode rumprobiert aber komme zu keinem Ergebnis.
g.drawImage(img, x, y, bgcolor, observer)
Hat vllt jemand einen Vorschlag wie ich daran gehen muss? Unten steht meine bisheriege Methode.
Aber wie bekomme ich es hin das die Methode mir ein Bild zeichnet? Ich hab schon eine ganze weile mit der drawImage() Methode rumprobiert aber komme zu keinem Ergebnis.
g.drawImage(img, x, y, bgcolor, observer)
Hat vllt jemand einen Vorschlag wie ich daran gehen muss? Unten steht meine bisheriege Methode.
Java:
private ResizableIcon getIcon()
{
ResizableIcon icon = new ResizableIcon()
{
int width = 32;
int height = 32;
public void revertToOriginalDimension()
{
}
public void setDimension(Dimension newDimension)
{
setWidth(newDimension.width);
setHeight(newDimension.height);
}
public void setHeight(int height)
{
this.height = height;
}
public void setWidth(int width)
{
this.width = width;
}
public int getIconHeight()
{
return height;
}
public int getIconWidth()
{
return width;
}
public void paintIcon(Component c, Graphics g, int x, int y)
{
g.setColor(Color.darkGray);
g.fillRect(x, y, getIconWidth(), getIconHeight());
g.setColor(Color.green);
g.drawRect(x, y, getIconWidth(), getIconHeight());
g.drawLine(x, y, x + getIconWidth() - 1, y + getIconHeight() - 1);
g.drawLine(x, y + getIconHeight() - 1, x + getIconWidth() - 1, y);
}
};