📄 statuspanel.java
字号:
/**
* This class models a HannoiTower.
*
* @author 程宇恒
* @version 1.0.0
*/
/******** STATUS PANEL ********
UI components for status messages and move counter
*/
import java.awt.*;
import javax.swing.*;
final class StatusPanel extends JPanel
{
private JTextField tfStatus, tfMoveCount ;
private Hanoi11 main;
// constructor
StatusPanel(Hanoi11 hanoi11)
{
main = hanoi11;
Hanoi11 _tmp = hanoi11;
setFont(Hanoi11.textFont);
tfStatus = new JTextField(50);
tfStatus.setForeground(Color.white);
tfStatus.setBackground(Color.darkGray);
tfStatus.setEditable(false);
tfMoveCount = new JTextField(6);
Hanoi11 _tmp1 = hanoi11;
tfMoveCount.setFont(Hanoi11.monoFont);
tfMoveCount.setForeground(Color.white);
tfMoveCount.setBackground(Color.darkGray);
tfMoveCount.setEditable(false);
add(tfStatus);
add(tfMoveCount);
add(new JLabel("<html><b><font color = white>MOVES</font></b></html>"));
validate();
}
void setMoveCount(int i)
{
String s = Integer.toString(i);
switch(s.length())
{
case 1:
s = " " + s ; break ;//length 4
case 2:
s = " " + s ; break ;//length 3
case 3:
s = " " + s ; break ;//length 2
case 4:
s = " " + s ; break ; //length 1
}
tfMoveCount.setText(s);
}
void setStatus(String s)
{
tfStatus.setText(s);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -