public class MyPanel extends JPanel { ImageIcon icon; Image img; public MyPanel() { icon = new ImageIcon("图片的路径"); img = icon.getImage(); } public void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), this); } }
public class picFrame extends JFrame implements ThreadProc, ActionListener, WindowListener { private JLabel jLabel, jForeground; private JPanel bottomPanel; private MyPanel centerPanel;//用MyPanel定义centerPanel 然后实例化就可以了 详细的过程不演示了 不懂留言问 private JButton jButton; private ClockThread clockThread; private int offset;