Hi,
im trying to make a simple program that sets on image visible when you click a button, and then the other one on when you click it again. This is what i have so far:
import java.awt.*; import javax.swing.*; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JButton; import javax.swing.JComponent; import java.awt.Toolkit; import java.awt.BorderLayout; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class DinoYesNo { public static void main(String[] args) { GridLayout myLayout = new GridLayout(2, 1); JFrame frame = new JFrame( "Yes No Dino"); frame.setSize(400,200); JPanel myPanel = new JPanel(); myPanel.setLayout(myLayout); //make GIF icons final ImageIcon dinoyes = new ImageIcon("S:\\dinoyes.gif"); final ImageIcon dinono = new ImageIcon("S:\\dinono.gif"); //make switcher button final JButton switcher = new JButton ("Yes/No"); ActionListener al = new ActionListener(){ public void actionPerformed(ActionEvent e){ int check = 0; if (check == 0){ dinoyes.setVisible(true); dinono.setVisible(false); check++; } else{ dinoyes.setVisible(false); dinono.setVisible(true); check--; } } }; switcher.addActionListener(al); switcher.setToolTipText("Switches yes and no"); myPanel.add(dinoyes); myPanel.add(dinono); myPanel.add(newButton); frame.getContentPane().add(myPanel); frame.setVisible(true); } }
it is giving me an error with "dinoyes.setVisible(true);" it says "cannot find symbol - method setVisible(boolean)"
any advice?
Joel