?? showpanel.java
字號:
package hideInfo;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.*;
public class ShowPanel extends JPanel {
/**
* 用于顯示載入的bmp文件的panel
*/
private Image image;
public ShowPanel() {
super();
}
public void setImage(Image image)
{
this.image=image;
}
public void paintComponent(Graphics gg)
{
super.paintComponent(gg);
if(this.image!=null) {
int w=this.image.getWidth(this);
int h=this.image.getHeight(this);
// System.out.println("w="+w);
// System.out.println("h="+h);
if (w<=0 && h<=0 ) return;
if (w>200 || h>200)
{
if(w>h)
{
double tmp=((double)w)/220;
h=(int) (h/tmp);
w=220; //把圖像按照比例縮小到可以放在Panel中顯示
}
else
{
double tmp=((double)h)/210;
w=(int) (w/tmp);
h=210;
}
}
// System.out.println("w="+w);
// System.out.println("h="+h);
gg.drawImage(this.image,(230-w)/2,(242-h)/2,w,h,this);//繪圖
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -