diff options
Diffstat (limited to 'src/cppcheckplus/text/MyPanel.java')
-rw-r--r-- | src/cppcheckplus/text/MyPanel.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/cppcheckplus/text/MyPanel.java b/src/cppcheckplus/text/MyPanel.java new file mode 100644 index 0000000..cec59ac --- /dev/null +++ b/src/cppcheckplus/text/MyPanel.java | |||
@@ -0,0 +1,31 @@ | |||
1 | package cppcheckplus.text; | ||
2 | |||
3 | import java.awt.BorderLayout; | ||
4 | import java.awt.Graphics; | ||
5 | import java.awt.Image; | ||
6 | |||
7 | import javax.swing.ImageIcon; | ||
8 | import javax.swing.JPanel; | ||
9 | |||
10 | import cppcheckplus.control.MyContorlUtil; | ||
11 | |||
12 | public class MyPanel extends JPanel{ | ||
13 | ImageIcon icon; | ||
14 | Image img; | ||
15 | public MyPanel(){ | ||
16 | // /img/HomeImg.jpg 是存放在你正在编写的项目的bin文件夹下的img文件夹下的一个图片 | ||
17 | icon=new ImageIcon(MyContorlUtil.getImage("control/images/back2.jpg")); | ||
18 | img=icon.getImage(); | ||
19 | } | ||
20 | public MyPanel(BorderLayout borderLayout) { | ||
21 | icon=new ImageIcon(MyContorlUtil.getImage("control/images/back2.jpg")); | ||
22 | img=icon.getImage(); | ||
23 | setLayout(borderLayout); | ||
24 | } | ||
25 | public void paintComponent(Graphics g) { | ||
26 | super.paintComponent(g); | ||
27 | //下面这行是为了背景图片可以跟随窗口自行调整大小,可以自己设置成固定大小 | ||
28 | g.drawImage(img, 0, 0,this.getWidth(), this.getHeight(), this); | ||
29 | } | ||
30 | } | ||
31 | |||