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