📄 graphframe.java
字号:
package datastructure;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class GraphFrame
extends AnimationFrame
implements ActionListener {
Graph graph;
private JButton helpButton;
private JButton closeButton;
static Dialogl dialogmessage;
static DiaGraph graphdata;
private boolean flag = true;
private JButton musicButton = new JButton("播放音乐");
public GraphFrame(Root Root) {
super("图的深度遍历算法演示窗口 (南昌航空工业学院-软件学院)", Root);
graph = new Graph();
init();
}
public void init() {
addWindowListener(new WindowClose(this, false));
super.initBase();
Container con = this.getContentPane();
con.add(graph, BorderLayout.CENTER);
super.controlPanel.add(graph.newButton);
super.controlPanel.add(graph.runButton);
super.controlPanel.add(graph.stepButton);
super.controlPanel.add(graph.stayButton);
helpButton = new JButton("帮 助");
closeButton = new JButton("退 出");
musicButton.addActionListener(this);
closeButton.setToolTipText("退出演示窗口");
closeButton.addActionListener(this);
super.controlPanel.add(helpButton);
super.controlPanel.add(closeButton);
super.controlPanel.add(musicButton);
helpButton.addActionListener(this);
dialogmessage = new Dialogl(this, "算法演示完成", true);
dialogmessage.setVisible(false);
graphdata = new DiaGraph(this, "建立演示数据", true);
graphdata.setVisible(false);
}
public void actionPerformed(ActionEvent actionevent) {
if (actionevent.getSource() == helpButton) {
if (Root.helpFrame != null) {
Root.helpFrame.dispose();
}
Root.helpFrame = new HelpFrame("/help/Graphics.html", super.root);
Root.helpFrame.setLocation(200, 100);
Root.helpFrame.showNewHtmlPage("/help/Graphics.html");
Root.helpIsOn = true;
Root.helpFrame.setVisible(true);
}
else if (actionevent.getSource() == closeButton) {
Root.clip.stop();
this.setVisible(false);
}
else if (actionevent.getSource() == musicButton) {
if (flag) {
Root.clip.loop();
musicButton.setText("关闭音乐");
flag = !flag;
}
else {
Root.clip.stop();
musicButton.setText("播放音乐");
flag = !flag;
}
}
}
public void kill() {
graph.stop();
}
public void Start() {
graph.start();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -