📄 indexframe.java
字号:
package datastructure;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class IndexFrame
extends AnimationFrame
implements ActionListener {
private JButton helpButton;
private JButton closeButton;
private Index index;
static DiaIndex newData;
private boolean flag = true;
private JButton musicButton = new JButton("播放音乐");
public IndexFrame(Root root) {
super("串的模式匹配算法演示窗口 (南昌航空工业学院-软件学院)", root);
helpButton = new JButton("帮 助");
closeButton = new JButton("退 出");
closeButton.setToolTipText("退出演示窗口");
helpButton.setToolTipText("查看帮助");
musicButton.addActionListener(this);
helpButton.addActionListener(this);
closeButton.addActionListener(this);
newData = new DiaIndex(this, "建立演示数据对话框", true);
index = new Index();
init();
}
public void kill() {
index.stop();
}
public void Start() {
index.start();
}
public void addListener()//加上windows监听器
{
addWindowListener(new WindowClose(this, false));
}
public void init() {
addWindowListener(new WindowClose(this, false));
super.initBase();
super.controlPanel.add(index.newButton);
super.controlPanel.add(index.runButton);
super.controlPanel.add(index.stepButton);
super.controlPanel.add(index.stayButton);
super.controlPanel.add(helpButton);
super.controlPanel.add(closeButton);
super.controlPanel.add(musicButton);
Container con = this.getContentPane();
con.add(index, BorderLayout.CENTER);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == helpButton) {
if (Root.helpFrame != null) {
Root.helpFrame.dispose();
}
Root.helpFrame = new HelpFrame("/help/StringIn.html", super.root);
Root.helpFrame.setLocation(200, 100);
Root.helpFrame.showNewHtmlPage("/help/StringIn.html");
Root.helpIsOn = true;
Root.helpFrame.setVisible(true);
}
else if (e.getSource() == closeButton) {
Root.clip.stop();
this.setVisible(false);
}
else if (e.getSource() == musicButton) {
if (flag) {
Root.clip.loop();
musicButton.setText("关闭音乐");
flag = !flag;
}
else {
Root.clip.stop();
musicButton.setText("播放音乐");
flag = !flag;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -