?? textpanel.java
字號:
/**
* @(#)TextPanel.java
* @A panel with 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 TextPanel extends JPanel
{
private int width;
private int height;
private int pound;
private String text;
private Color color;
//construct a text panel with specified width,height,pound of the text and text
public TextPanel(int a,int b,int c,String s)
{
width = a;
height = b;
pound = c;
text = s;
color = Color.white;
setBackground(Color.black);
setPreferredSize(new Dimension(width,height));
setVisible(true);
}
//set the color of the text
public void setColor(Color c)
{
color = c;
repaint();
}
//set the text of the text panel
public void setText(String s)
{
text = s;
repaint();
}
//draw the text of the text panel
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
g.setColor(color);
g.setFont(new Font("Monospaced",Font.BOLD,pound));
g.drawString(text,0,height - pound);
}
} //end class TextPanel
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -