Netbeans GUI Components don't update after modification
I can't find anyone who has this same problem, so it might just be a simple fix, but I'm creating a Jeopardy game in Netbeans. I created a JPanel Form to design each of the individual squares, and then I added 36 of them (for the 6x6 board) to another JPanel Form which represents the board. That works great, but the problem is that after I add all 36 squares to the board, they are stuck in 开发者_如何学运维the state at which I added them. If I change the position or color of a label in the Question JPanel Form, it does not update in the Jeopardy Board JPanel Form. I don't want to re-add 36 Questions and rename all the variables every time I make a change to a sub-component. Is there a way to keep it all in sync?
If I change the position or color of a label in the Question JPanel Form,
1). labels are non opaque which means changing the background color will have no effect. You need to make the label opaque when you create it when you want to alter the background:
label.setOpaque( true );
2) Once you set up your jeopardy board you should have no need to change the position of the label. Once the question is answer, I would just clear the text in the label by using:
label.setText("");
For each new round of jeopardy again all you need to do is reset the background for every label and then reset the text for every label. There should be no need to recreate all the labels.
You could try calling the revalidate() method of the JPanel.
Consider refactoring and renaming all folders you personally created in the project. This should resolve the issue.
精彩评论