おそらく、下記URLに書かれてる問題と同じだと思うのですが良くわかりません。切り替えの概念はなんとなく分かります。
http://detail.chiebukuro.yahoo.co.jp/qa ... 1036862235
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Parts1 extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
private JPanel contentPane;
//
private ImageIcon Img1 = new ImageIcon("C:\\Java\\Kadai\\workspace\\MahjongHaiGazou\\1.gif"); //1萬
private JButton MonndaiButton;
private JLabel LabelDayo0;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Parts1 frame = new Parts1();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public Parts1() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 592, 371);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
MonndaiButton = new JButton("\u554F\u984C\u4F5C\u6210");
MonndaiButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
ImageIcon Img0 = new ImageIcon("C:\\Java\\Kadai\\workspace\\MahjongHaiGazou\\0.gif"); //裏牌
LabelDayo0 = new JLabel(Img0);
}
});
MonndaiButton.setBounds(54, 276, 91, 21);
contentPane.add(MonndaiButton);
LabelDayo0 = new JLabel(Img1); //
LabelDayo0.setBounds(30, 100, 78, 40);
contentPane.add(LabelDayo0);
}
}