📄 lcd.java
字号:
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.JPanel;
import java.awt.*;
public class Lcd extends JPanel implements ActionListener {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
String cmd = arg0.getActionCommand();
if(cmd.equals("clear"))
{ clear();
}
else if(count<MAX)
{
if(count == 0 )
in = cmd;
else
in += cmd;
d.setText(h1+in+ht);
count++;
}
} //joptionpane.showMessageDialog(NULL, title);
protected void clear()
{
count = 0 ; in ="0";
d.setText(h1+in+ht);
}
Lcd(int size)
{
MAX = size;
setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLoweredBevelBorder(),BorderFactory.createEmptyBorder(5,10,5,10)));
d = new JLabel(in , JLabel.RIGHT);
setLayout(new BorderLayout());
add( d, BorderLayout.CENTER);
clear();
}
protected String in = "0";
protected int count= 0;
protected static int MAX;
protected JLabel d;
protected String h1 = "<html><p aligh= right>"+ "<fontcolor=blue size=+1><tt><b>";
protected String ht= "</font></b></tt></p></html>";
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -