📄 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 + -