Currently I use Netbeans IDE 8. 0, I want to replace skin JPanel
when I choose a radio button. The problem which I faced two strong panel in form1
with radio button in form2
. Two of them are not in a form. I tried to research in Google but no answer.
In source code, which have I recognized in error since the panel in other form, then what can I do?
Then source code radio button which I created:
private void rwhiteMouseClicked(java.awt.event.MouseEvent evt) {
rgreen.setSelected(false);
rred.setSelected(false);
rblack.setSelected(false);
jPanel1.setBackground(new java.awt.Color(255, 255, 255));
}
private void rgreenMouseClicked(java.awt.event.MouseEvent evt) {
rwhite.setSelected(false);
rred.setSelected(false);
rblack.setSelected(false);
jPanel1.setBackground(new java.awt.Color(0, 204, 0))
}
private void rredMouseClicked(java.awt.event.MouseEvent evt) {
rgreen.setSelected(false);
rwhite.setSelected(false);
rblack.setSelected(false);
jPanel1.setBackground(new java.awt.Color(255, 0, 0));
}
private void rblackMouseClicked(java.awt.event.MouseEvent evt) {
rgreen.setSelected(false);
rred.setSelected(false);
rwhite.setSelected(false);
jPanel1.setBackground(new java.awt.Color(0, 0, 0));
}
ItemListener
" That's less optimal than anActionListener
in that it will fire two events for every time a single button is clicked on. "don't forget to call thesetOpaque(true)
method on your panel" It's the default state of aJPanel
. Perhaps you're thinking ofJLabel
. – Andrew ThompsonButtonGroup
as suggested by @HovercraftFullOfEels 8 hours ago, there would be no need to check! The button that fires the event would be selected. You've implemented that advice, right? Otherwise we're just wasting our time trying to help. – Andrew Thompson