如何"缝制"一个JPanel到JFrame上面

来源:互联网 发布:塔吉特百货大数据 编辑:程序博客网 时间:2024/04/29 09:48
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;
1 0
原创粉丝点击