Friday, 23 August 2013

Add components dynamicly to Java Swing Form with JButton

Add components dynamicly to Java Swing Form with JButton

trying to make a Card Game, when I click a jButton he places 5 new
ToggleButtons that represent 5 Cards. The problem is I tryed to created a
new JPanel class with those 5 ToggleButton. Now when i click the Button I
want this panel to appear on my jForm.
Tryed this:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
add(new jPanelFiveCard());
revalidate();
}
Nothing happens when I click it. Tryed a lot of other ways... like
initiate a public static JFrame and trying to add the components to it...
tryed repaint... nothing works.
Sorry to bother and thanks for the help.

No comments:

Post a Comment