Die Präsentation wird geladen. Bitte warten

Die Präsentation wird geladen. Bitte warten

© 2006 MPohlig Grundkurs Informatik mit Java 1 JFrame-Vorlage Step by step by step by step by step by step by step by step by.

Ähnliche Präsentationen


Präsentation zum Thema: "© 2006 MPohlig Grundkurs Informatik mit Java 1 JFrame-Vorlage Step by step by step by step by step by step by step by step by."—  Präsentation transkript:

1 © 2006 MPohlig Grundkurs Informatik mit Java 1 JFrame-Vorlage Step by step by step by step by step by step by step by step by

2 © 2006 MPohlig Grundkurs Informatik mit Java 2 step 1 public class HalloWelt{ public static void main(String[] args){ }

3 © 2006 MPohlig Grundkurs Informatik mit Java 3 step 2 public class HalloWelt{ public HalloWelt(){ } public static void main(String[] args){ } Mit Konstruktor, wird aber nicht aufgerufen

4 © 2006 MPohlig Grundkurs Informatik mit Java 4 Step 3 public class HalloWelt{ public HalloWelt(){ } public static void main(String[] args){ new HalloWelt(); } Konstruktor wird aufgerufen

5 © 2006 MPohlig Grundkurs Informatik mit Java 5 Step 4 import javax.swing.*; public class HalloWelt extends JFrame{ public HalloWelt(){ } public static void main(String[] args){ new HalloWelt(); } Man sieht aber nichts!

6 © 2006 MPohlig Grundkurs Informatik mit Java 6 Step 5 import javax.swing.*; public class HalloWelt extends JFrame{ public HalloWelt(){ setVisible(true); } public static void main(String[] args){ new HalloWelt(); } Bilderrahmen hat keinen Titel und das Objekt existiert noch, auch wenn es weggeklickt wird.

7 © 2006 MPohlig Grundkurs Informatik mit Java 7 step 6 import javax.swing.*; public class HalloWelt extends JFrame{ public HalloWelt(String titel){ setVisible(true); } public static void main(String[] args){ new HalloWelt("Ich bin ein JFrame-Objekt"); }

8 © 2006 MPohlig Grundkurs Informatik mit Java 8 step 7 import javax.swing.*; public class HalloWelt extends JFrame{ public HalloWelt(String titel){ super(titel); setVisible(true); } public static void main(String[] args){ new HalloWelt("Ich bin ein JFrame-Objekt"); }

9 © 2006 MPohlig Grundkurs Informatik mit Java 9 step 8 import javax.swing.*; public class HalloWelt extends JFrame{ public HalloWelt(String titel){ super(titel); setDefaultCloseOperation(EXIT_ON_CLOSE); setVisible(true); } public static void main(String[] args){ new HalloWelt("Ich bin ein JFrame-Objekt"); } Jetzt hört das JFrame-Objekt auf zu "existieren", wenn man es wegklickt.

10 © 2006 MPohlig Grundkurs Informatik mit Java 10 step 9 import javax.swing.*; public class HalloWelt extends JFrame{ public HalloWelt(String titel){ super(titel); setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(300, 300); setVisible(true); } public static void main(String[] args){ new HalloWelt("Ich bin ein JFrame-Objekt"); } Das JFrame-Objekt hat jetzt von Anfang an eine vernünftige Größe.

11 © 2006 MPohlig Grundkurs Informatik mit Java 11 step 10 import javax.swing.*; import java.awt.*; public class HalloWelt extends JFrame{ public HalloWelt(String titel){ super(titel); setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(300, 300); Container cp = getContentPane(); cp.setLayout(new BorderLayout()); setVisible(true); } public static void main(String[] args){ new HalloWelt("Ich bin ein JFrame-Objekt"); } Jetzt haben wir einen Behälter, der grafische Objekte aufnehmen kann.

12 © 2006 MPohlig Grundkurs Informatik mit Java 12 Aufruf der Vorlage für einen JFrame Vorlage JFrame

13 © 2006 MPohlig Grundkurs Informatik mit Java 13 Hallo Welt als JFrame schriftzug wird als JLabel deklariert schriftzug wird durch Erzeugen initialisiert und dem Behälter zugefügt


Herunterladen ppt "© 2006 MPohlig Grundkurs Informatik mit Java 1 JFrame-Vorlage Step by step by step by step by step by step by step by step by."

Ähnliche Präsentationen


Google-Anzeigen