Hey guys I have a simple question. Do I have to manually tell a panel to update or something? And if so how?
Right now using this code
(Note this is just to test concepts)import javax.swing.*; import java.awt.*; import java.awt.event.*; public class AdvTimeGame extends JFrame implements ActionListener { public static void main(String[] args) { new AdvTimeGame(); } private JButton b1; private JTextField field1; private JLabel label1; private JLabel label2; JPanel panel1 = new JPanel(); ImageIcon pic1 = new ImageIcon(AdvTimeGame.class.getResource("FinnHead.png")); public AdvTimeGame() { label1 = new JLabel("Choose your name:"); label2 = new JLabel(); field1 = new JTextField(15); field1.setToolTipText("Choose your name"); b1 = new JButton("Begin Game"); field1.addActionListener(this); b1.addActionListener(this); panel1.add(new JLabel(pic1)); panel1.add(label1); panel1.add(field1); panel1.add(b1); panel1.add(label2); this.add(panel1); this.setTitle("AdventureTime"); this.setVisible(true); this.setSize(300,400); this.setIconImage(Toolkit.getDefaultToolkit().getImage("FinnHead.png")); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public void actionPerformed(ActionEvent e) { if (e.getSource() == b1) { } addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { panel1.add(new JLabel(pic1)); } }); } }
It will do what I want, but the frame dosent add the new pictures until your minimize and then reopen the program.
Please Help.
-Duster