47 lines
1 KiB
Java
47 lines
1 KiB
Java
|
package de.itsblue.ConnectFour;
|
||
|
|
||
|
import javax.swing.JButton;
|
||
|
|
||
|
import javax.swing.*;
|
||
|
import java.awt.*;
|
||
|
|
||
|
public class ButtonRow extends JPanel{
|
||
|
|
||
|
JButton inputButtons[];
|
||
|
int buttoncount = 0;
|
||
|
|
||
|
public void InitButton() {
|
||
|
|
||
|
|
||
|
// configure the layout
|
||
|
this.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
|
||
|
|
||
|
for (int i = 0; i < this.buttoncount; i++) {
|
||
|
this.inputButtons[i] = new JButton();
|
||
|
this.inputButtons[i].setText(""+i);
|
||
|
this.add(this.inputButtons[i]);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
ButtonRow(int buttoncount) {
|
||
|
this.buttoncount = buttoncount;
|
||
|
this.inputButtons = new JButton[buttoncount];
|
||
|
this.InitButton();
|
||
|
System.out.println("test");
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void paint(Graphics g){
|
||
|
for (int i = 0; i < this.buttoncount; i++) {
|
||
|
|
||
|
this.inputButtons[i].setPreferredSize(new Dimension(this.getWidth()/this.buttoncount, this.getHeight()));
|
||
|
}
|
||
|
|
||
|
super.paint(g);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|