well I’m trying to program in a simple gui into my game and I’ve kind of hit a snag which is stopping me from progressing.
In my game I have 2 JFrame (just like in KGPIJ wormchase example). In the first Frame I have the main game screen in which you can see the eye saw game and below that we have the second Jframe which has two JTextField’s. However when the game loads up the Textfields are not drawn properly and when the game is resized they mess up again. It is only after I give them focus that they draw properly. I’m presuming I have to call repaint for the compoment but I’d have no idea how to do this. Its also annoying me because in Oreillys code he does not have these issues (His program runs perfectly). Below is a screenshow to show the issue.
http://img411.imageshack.us/img411/5565/guipuzzel.png
my code for this can be seen below
private void createGUI()
{
Container c = getContentPane();
c.setLayout( new BorderLayout() );
gd = new GameDraw();
c.add(gd, "Center");
JPanel ctrls = new JPanel();
ctrls.setLayout(new GridLayout(2, 1, 1, 1));
chatInput = new JTextField("Welcome to my test game");
chatBox = new JTextField("test");
ctrls.add(chatInput);
ctrls.add(chatBox);
c.add(ctrls, "South");
}
createGui gets called in public void init() {}
Secondaly so I do not have to keep bugging you guys as I know I’ll have issues with this would someone be able to give me advice in adding in swing compoments to the Jframe in which the game is drawn. Is what I’m aiming for here is a character window. The issue I’m having here is that if I try and add a compoment to the games JFrame it just takes up the entire screen >.<.