Fastchiller
Grünschnabel
Hi @ all
Habe hier wieder mal so ein Problem mit den Buttons.Nämlich er will die nicht zum Panel hinzufügen.
vielleicht wisst ihr woran es liegt?
mfg Fastchiller
Habe hier wieder mal so ein Problem mit den Buttons.Nämlich er will die nicht zum Panel hinzufügen.
vielleicht wisst ihr woran es liegt?
mfg Fastchiller
Code:
package biz.sfsservices.hros.tictactoe;
import javax.swing.*;
import java.awt.*;
import javax.swing.JButton;
import javax.swing.JPanel;
public class GameFrame extends JFrame {
private static final long serialVersionUID = 1L;
private JDesktopPane desktopgame = null;
private JLabel lb_playername = null;
private JLabel lb_rivalname = null;
private JLabel lb_gamelevel = null;
private JButton bt_endgame = null;
private JPanel pa_buttonfield = null;
private JButton[] bt = null;
/**
* This method initializes desktopgame
*
* @return javax.swing.JDesktopPane
*/
private JDesktopPane getDesktopgame() {
if (desktopgame == null) {
lb_gamelevel = new JLabel();
lb_gamelevel.setBounds(new Rectangle(190, 10, 120, 20));
lb_gamelevel.setText(" Spielmodus: Leicht");
lb_rivalname = new JLabel();
lb_rivalname.setBounds(new Rectangle(400, 10, 100, 20));
lb_rivalname.setText("Gegnername: 0");
lb_playername = new JLabel();
lb_playername.setBounds(new Rectangle(10, 10, 100, 20));
lb_playername.setText(" Spielername: 0");
desktopgame = new JDesktopPane();
desktopgame.add(lb_playername, null);
desktopgame.add(lb_rivalname, null);
desktopgame.add(lb_gamelevel, null);
desktopgame.add(getBt_endgame(), null);
desktopgame.add(getPa_buttonfield(), null);
}
return desktopgame;
}
/**
* This method initializes bt_endgame
*
* @return javax.swing.JButton
*/
private JButton getBt_endgame() {
if (bt_endgame == null) {
bt_endgame = new JButton();
bt_endgame.setBounds(new Rectangle(380, 296, 115, 20));
bt_endgame.setText("Spiel beenden");
}
return bt_endgame;
}
/**
* This method initializes pa_buttonfield
*
* @return javax.swing.JPanel
*/
private JPanel getPa_buttonfield() {
if (pa_buttonfield == null) {
pa_buttonfield = new JPanel();
pa_buttonfield.setLayout(new GridLayout(3,3,1,1));
pa_buttonfield.setBounds(new Rectangle(139, 52, 250, 232));
pa_buttonfield.add(getBt(), null);
}
return pa_buttonfield;
}
/**
* This method initializes bt
*
* @return javax.swing.JButton
*/
private JButton[] getBt() {
if (bt == null) {
bt = new JButton[9];
}
return bt;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
SwingUtilities.invokeLater(new Runnable() {
public void run() {
GameFrame thisClass = new GameFrame();
thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
thisClass.setVisible(true);
}
});
}
/**
* This is the default constructor
*/
public GameFrame() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(530, 367);
this.setContentPane(getDesktopgame());
this.setTitle("TicTacToe");
}
} // @jve:decl-index=0:visual-constraint="110,2"