summaryrefslogtreecommitdiffstats
path: root/src/cppcheckplus/text/MyPanel.java
blob: cec59accafe50c14ef3c6f7e4e8546f5f5e9a38a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package cppcheckplus.text;

import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

import cppcheckplus.control.MyContorlUtil;

public class MyPanel extends JPanel{
	ImageIcon icon;  
    Image img; 
    public MyPanel(){
    	 //  /img/HomeImg.jpg 是存放在你正在编写的项目的bin文件夹下的img文件夹下的一个图片  
        icon=new ImageIcon(MyContorlUtil.getImage("control/images/back2.jpg"));  
        img=icon.getImage(); 
    }
    public MyPanel(BorderLayout borderLayout) {
    	icon=new ImageIcon(MyContorlUtil.getImage("control/images/back2.jpg"));  
        img=icon.getImage(); 
        setLayout(borderLayout);
	}
	public void paintComponent(Graphics g) {  
        super.paintComponent(g);  
        //下面这行是为了背景图片可以跟随窗口自行调整大小,可以自己设置成固定大小  
        g.drawImage(img, 0, 0,this.getWidth(), this.getHeight(), this);  
    } 
}