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?>
Warum läuft die Hauptmethode nicht? ⇐ Java
-
- Similar Topics
- Replies
- Views
- Last post
-
-
Sind alle Objekte in Java erstellt, sind statische Objekte in der Hauptmethode?
by Anonymous » » in Java - 0 Replies
- 27 Views
-
Last post by Anonymous
-