Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.marvin.oopLabor2;
- public class Main {
- public static void main(String[] args)
- {
- MyFrameA ersteFenster = new MyFrameA();
- ersteFenster.setTitle(1111);
- MyFrameB zweitesFenster = new MyFrameB();
- zweitesFenster.setTitle(2013);
- new MyFrameC("zahlen",300,100);
- }
- }
- //-------------------------------------------------------
- package de.marvin.oopLabor2;
- import javax.swing.JFrame;
- public class MyFrameA extends JFrame {
- private static final long serialVersionUID = 1L;
- MyFrameA()
- {
- this.setSize(200,200);
- this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- this.setLocation(300,300);
- this.setResizable(false);
- this.setVisible(true);
- }
- protected void setTitle(int titel)
- {
- this.setTitle(Integer.toString(titel));
- }
- }
- //-------------------------------------------------------
- package de.marvin.oopLabor2;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- public class MyFrameB extends MyFrameA {
- private static final long serialVersionUID = 1L;
- MyFrameB()
- {
- this.setLocation(600,300);
- this.setLabels();
- }
- protected void setLabels()
- {
- JPanel FensterInFenster = new JPanel();
- FensterInFenster.add(new JLabel("Hallo Flensburg"));
- FensterInFenster.add(new JLabel("Hallo Deutschland"));
- FensterInFenster.add(new JLabel("Hallo Welt"));
- this.add(FensterInFenster);
- }
- protected void setTitle(int titel)
- {
- this.setTitle(Integer.toString(titel));
- }
- }
- //-------------------------------------------------------
- package de.marvin.oopLabor2;
- import java.awt.FlowLayout;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- public class MyFrameC extends MyFrameA {
- private static final long serialVersionUID = 1L;
- MyFrameC(String title,int groesse,int anzahlDerWerte)
- {
- this.setSize(groesse,groesse);
- this.setLocation(900,300);
- this.setTitle(title);
- this.setLayout(new FlowLayout());
- this.unsereLabels(anzahlDerWerte,this);
- }
- protected void unsereLabels(int anzahlDerWerte,JFrame meinFenster)
- {
- JLabel[] vieleFenster = new JLabel[anzahlDerWerte+1];
- for(int i =1;i < vieleFenster.length;i++)
- {
- if(i%2==0)
- {
- vieleFenster[i] = new JLabel(Integer.toString(i));
- meinFenster.add(vieleFenster[i]);
- }
- }
- }
- protected void setTitle(int titel)
- {
- this.setTitle(Integer.toString(titel));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement