I'm having an issue where, when I run the program, I'm able to select one smiley to be active, and I can change this from the JRadio button choices to different selections and it'd work cause I'm testing it with changing colors. My issue is that I'm only able to change active panels by descending order. I can't go back to a previous one. When I run the program and select smiley_a, I'm able to change its colors, but when I select smiley_b, smiley_a continues the be the one that's changing. Once I get to A, I can't go back to or C or D, and if I start with B, I can't go back to C or D, only to A, and so forth... I'm able to click, but it doesn't update which frame is active.
@Override
public void actionPerformed(ActionEvent e) {
String action = e.getActionCommand();
if (action.equals("Change Colors")) {
update();
selector();
}
if (action.equals("Face +")) {
System.out.println("work");
//frameAsmiley.setSize(20);
//System.out.println("work");
//frameAsmiley.repaint();
}
if (action.equals("Face -")) {
frameAsmiley.setSize(20);
frameAsmiley.repaint();
}
}
@Override
public void itemStateChanged(ItemEvent e) {
Object source = e.getSource();
if (source == a) {
smiley_a = true;
update();
}if (source == b) {
smiley_b = true;
update();
}if (source== c) {
smiley_c = true;
update();
}if (source == d) {
smiley_d = true;
update();
}
if (source == glasses_on) {
cube_a.repaint();
}if (source == glasses_off) {
cube_a.repaint();
}if (source== c) {
smiley_c = true;
update();
}if (source == d) {
smiley_d = true;
update();
}
if(e.getStateChange() == ItemEvent.SELECTED){
if (emotions.getSelectedItem().equals("Smile!")) {
}
if (emotions.getSelectedItem().equals("Angry!")) {
}if (emotions.getSelectedItem().equals("Sad!")) {
}if (emotions.getSelectedItem().equals("Shock!")) {
}if (emotions.getSelectedItem().equals("Wink!")) {
}
}
}
class OutputScreen extends JPanel {
OutputScreen() {
setPreferredSize(new Dimension(600, 400));
}
}
}
Aucun commentaire:
Enregistrer un commentaire