graphframe.java

来自「本软件是使用java 开发的」· Java 代码 · 共 96 行

JAVA
96
字号
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 + =
减小字号Ctrl + -
显示快捷键?