📄 picturepanel.java
字号:
/**
* @(#)PicturePanel.java
* @A panel with a picture.
*
* @Link Scholes
* @version 1.00 2008/7/21
*/
package GUI;
//Java core packages
import java.awt.*;
//Java extension packages
import javax.swing.*;
public class PicturePanel extends JPanel
{
private int width;
private int height;
private String picture;
private ImageIcon icon;
//construct a picture panel with specified width,height and picture
public PicturePanel(int a,int b,String s)
{
width = a;
height = b;
picture = s;
setPreferredSize(new Dimension(width,height));
setVisible(true);
}
//set the picture of the picture panel
public void setPicture(String s)
{
picture = s;
repaint();
}
//draw the picture of the picture panel
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
icon = new ImageIcon(picture);
g.drawImage(icon.getImage(),0,0,null);
}
} //end class PicturePanel
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -