i got the program to run with labels but i cant get it to use images. im a beginner and this is all i can come up with so far. it runs but i dont understand implementing images into this code.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class CardLayoutExample extends JFrame implements KeyListener
{
private Container pane = getContentPane();
private CardLayout layout = new CardLayout();
public CardLayoutExample()
{
pane.setLayout(layout);
pane.add(new JLabel("hey", SwingConstants.CENTER), "hey");
pane.add(new JLabel("what", SwingConstants.CENTER), "what");
pane.add(new JLabel("is", SwingConstants.CENTER), "is");
pane.add(new JLabel("your", SwingConstants.CENTER), "your");
pane.add(new JLabel("first", SwingConstants.CENTER), "first");
pane.add(new JLabel("name", SwingConstants.CENTER), "name");
addKeyListener(this);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("CardLayout Example");
setSize(410,310);
setVisible(true);
}
public void keyTyped(KeyEvent event)
{
layout.next(pane);
}
public void keyPressed(KeyEvent event){}
public void keyReleased(KeyEvent event){}
public static void main(String args[])
{
CardLayoutExample top = new CardLayoutExample();
}
}