Simpelt Graphics problem..
Hej, .. Jeg er ved at prøve at lave et komponent med udgangspunkt i noget kode jeg har fundet. Det virker bare ikke - spørgsmålet er hvorfor !!import java.awt.*;
public class Filosofferne extends Frame {
private Fork myFork;
/** Creates a new instance of Filosofferne */
public Filosofferne() {
myFork = new Fork(10,10);
}
public void paint(java.awt.Graphics g) {
myFork.paint(g);
}
public static void main(String[] args) {
Filosofferne myFilo = new Filosofferne();
myFilo.setSize(350,300); // sæt vinduets størrelse
myFilo.setTitle("GrafiskVindue"); // sæt vinduets titel
myFilo.setVisible(true); // åbn vinduet
}
class Component {
/** Backpointer to the Filosof*/
protected Filosofferne filosof;
/** Component location */
protected int x, y;
}
class Fork extends Component {
public Fork(int xPos, int yPos) {
x = xPos;
y = yPos;
}
public void paint(Graphics g) {
g.drawString("Here should be a fork!", x, y);
}
}
}
