?? picturetextpanel.java
字號:
/**
* @(#)PictureTextPanel.java
* @A panel with picture and text.
*
* @Link Scholes
* @version 1.00 2008/7/21
*/
package GUI;
//Java core packages
import java.awt.*;
//Java extension packages
import javax.swing.*;
public class PictureTextPanel extends JPanel
{
private int width;
private int height;
private String picture;
private String text;
private ImageIcon icon;
//construct a picture text panel with specified width,height,picture and text
public PictureTextPanel(int a,int b,String s,String t)
{
width = a;
height = b;
picture = s;
text = t;
setPreferredSize(new Dimension(width,height));
setVisible(true);
}
//set the picture of the picture text panel
public void setPicture(String s)
{
picture = s;
repaint();
}
//draw the picture and text of the picture text panel
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
icon = new ImageIcon(picture);
g.drawImage(icon.getImage(),0,0,null);
g.setColor(Color.white);
g.setFont(new Font("Monospaced",Font.BOLD,32));
g.drawString(text,16,height - 4);
}
} //end class PictureTextPanel
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -