Page 1 of 1

Warum läuft die Hauptmethode nicht?

Posted: 05 Sep 2025, 00:32
by Anonymous
Ein bisschen verwirrt über die öffentliche statische Leere -Hauptmethode in Java und hoffte, dass jemand helfen könnte. Ich habe zwei Klassen < /p>

public class theGame {
public static void main(String[] args) {
lineTest gameBoard = new lineTest();
}
< /code>

und < /p>

public class lineTest extends JPanel {

public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(Color.red);
g2d.drawLine(100, 100, 100, 200);
}

public static void main(String[] args) {
lineTest points = new lineTest();
JFrame frame = new JFrame("Points");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(points);
frame.setSize(250, 200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
< /code>

Mein Programm zeichnet die Zeile leider nicht. Ich versuche herauszufinden, warum die Hauptmethode in der Linetest -Klasse nicht eingeht?>