Auf Thema antworten

Das in eine andere Klasse zu packen solltest du wohl noch alleine hinkriegen, oder?

Und das Problem, das die Buttons erst ab dem fünften Slot eingefügt werden sollen, lässt sich doch einfach so lösen:

[code=Java]

public static final int MAXBUTTONS = 25;


private JButton[] buttons = new JButton[ MAXBUTTONS ];

private int nbuttons = 5;


@ Override

public void actionPerformed( ActionEvent e ) {

   

    if ( nbuttons < MAXBUTTONS ) {

       

        JButton button = new JButton( "Ich bin ein JButton" );

       

        buttons[ nbuttons++ ] = button;

       

    }

   

}

[/code]



Oben