📄 mainframe.java
字号:
package com.will.eightnums;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author Will Wang
* @version 1.0
*/
public class MainFrame
extends JFrame implements Runnable {
BorderLayout borderLayout1 = new BorderLayout();
JPanel jMainPanel = new JPanel();
JPanel jDataPanel = new JPanel();
JButton jButtonRun = new JButton();
JButton jButtonDisplay = new JButton();
JRadioButton jBreadthRadioButton = new JRadioButton();
JRadioButton jBSRadioButton = new JRadioButton();
JRadioButton jDepthRadioButton = new JRadioButton();
JRadioButton jDSRadioButton = new JRadioButton();
JPanel jOptionPanel = new JPanel();
GridBagLayout gridBagLayout1 = new GridBagLayout();
Border border1;
TitledBorder titledBorder1;
ButtonGroup buttonGroup1 = new ButtonGroup();
JPanel jSelectPanel = new JPanel();
JPanel jDisplayPanel = new JPanel();
JPanel jStartPanel = new JPanel();
JPanel jTargetPanel = new JPanel();
Border border2;
Border border3;
Border border4;
GridLayout gridLayout2 = new GridLayout();
GridBagLayout gridBagLayout2 = new GridBagLayout();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
GraphPanel jDrawStartPanel = new GraphPanel(1);
BorderLayout borderLayout3 = new BorderLayout();
BorderLayout borderLayout4 = new BorderLayout();
GraphPanel jDrawTargetPanel = new GraphPanel(1);
JSpinner jSpinner1 = new JSpinner();
NumberModel spinnerNumberModel = new NumberModel(0, 0, 100, 1);
JPanel jDeepPanel = new JPanel();
GraphPanel jDrawDisplayPanel = new GraphPanel(2);
BorderLayout borderLayout5 = new BorderLayout();
JPanel jPanel4 = new JPanel();
JList jList1 = new JList();
ListModel listModel;
JScrollPane jScrollPane1 = new JScrollPane();
BorderLayout borderLayout2 = new BorderLayout();
JPanel jButtonPanel = new JPanel();
Seeker seeker = new Seeker();
boolean isOpened = false;
JMenuBar jMenuBar1 = new JMenuBar();
JMenu jMenuFile = new JMenu();
JMenuItem jMenuFileExit = new JMenuItem();
JMenu jMenuHelp = new JMenu();
JMenuItem jMenuAboutItem = new JMenuItem();
Thread timer;
public MainFrame() {
try {
jbInit();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
void jbInit() throws Exception {
border1 = BorderFactory.createLineBorder(SystemColor.controlText, 1);
titledBorder1 = new TitledBorder(BorderFactory.createEtchedBorder(Color.
white, new Color(148, 145, 140)), "选项");
border2 = BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.white,
Color.white,
new Color(103, 101, 98),
new Color(148, 145, 140));
border3 = BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.white,
Color.white,
new Color(103, 101, 98),
new Color(148, 145, 140));
border4 = BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.white,
Color.white,
new Color(103, 101, 98),
new Color(148, 145, 140));
this.getContentPane().setLayout(borderLayout1);
jDataPanel.setAlignmentX( (float) 0.5);
jDataPanel.setDebugGraphicsOptions(0);
jDataPanel.setMaximumSize(new Dimension(32767, 32767));
jDataPanel.setMinimumSize(new Dimension(147, 218));
jDataPanel.setOpaque(true);
jDataPanel.setLayout(borderLayout2);
jButtonRun.setText("执行");
jButtonDisplay.setText("演示");
jButtonRun.addActionListener(new MainFrame_jButtonRun_actionAdapter(this));
jButtonDisplay.addActionListener(new MainFrame_jButtonDisplay_actionAdapter(this));
jBreadthRadioButton.setForeground(Color.black);
jBreadthRadioButton.setAlignmentY( (float) 0.5);
jBreadthRadioButton.setText("广度优先");
jBreadthRadioButton.setSelected(true);
seeker.setType(1);
jBreadthRadioButton.addActionListener(new
MainFrame_jRadioButton_actionAdapter(this));
jBSRadioButton.setText("最佳优先A*");
jBSRadioButton.addActionListener(new
MainFrame_jRadioButton_actionAdapter(this));
jDepthRadioButton.setText("深度优先");
jDepthRadioButton.addActionListener(new
MainFrame_jRadioButton_actionAdapter(this));
jDSRadioButton.setText("深度优先+启发函数");
jDSRadioButton.addActionListener(new
MainFrame_jRadioButton_actionAdapter(this));
this.getContentPane().setBackground(SystemColor.controlLtHighlight);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setLocale(java.util.Locale.getDefault());
this.setResizable(false);
this.setState(Frame.NORMAL);
this.addWindowListener(new MainFrame_this_windowAdapter(this));
this.setSize(new Dimension(500, 480));
this.setJMenuBar(jMenuBar1);
jMenuFile.setText("文件");
jMenuFileExit.setText("退出");
jMenuFile.add(jMenuFileExit);
jMenuHelp.setText("帮助");
jMenuAboutItem.setText("关于");
jMenuHelp.add(jMenuAboutItem);
jMenuBar1.add(jMenuFile);
jMenuBar1.add(jMenuHelp);
jMenuAboutItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jMenuAboutItem_actionPerformed(e);
}
});
jMenuFileExit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jMenuFileExit_actionPerformed(e);
}
});
jMainPanel.setPreferredSize(new Dimension(400, 400));
jMainPanel.setLayout(gridBagLayout2);
jOptionPanel.setLayout(gridBagLayout1);
jOptionPanel.setBorder(titledBorder1);
jSelectPanel.setLayout(gridLayout2);
gridLayout2.setColumns(2);
gridLayout2.setRows(1);
jStartPanel.setBorder(border2);
jStartPanel.setLayout(borderLayout3);
jTargetPanel.setBorder(border3);
jTargetPanel.setLayout(borderLayout4);
jDisplayPanel.setBorder(border4);
jDisplayPanel.setDebugGraphicsOptions(0);
jDisplayPanel.setLayout(borderLayout5);
jLabel1.setFont(new java.awt.Font("宋体", 0, 12));
jLabel1.setForeground(Color.blue);
jLabel1.setMinimumSize(new Dimension(27, 15));
jLabel1.setRequestFocusEnabled(true);
jLabel1.setText("起始状态");
jLabel2.setFont(new java.awt.Font("宋体", 0, 12));
jLabel2.setForeground(Color.red);
jLabel2.setMinimumSize(new Dimension(48, 15));
jLabel2.setRequestFocusEnabled(true);
jLabel2.setText("目标状态");
jLabel3.setFont(new java.awt.Font("宋体", 0, 14));
jLabel3.setText("过程展示");
jDrawTargetPanel.setDebugGraphicsOptions(0);
jSpinner1.setMinimumSize(new Dimension(27, 22));
jSpinner1.setPreferredSize(new Dimension(60, 22));
jSpinner1.setToolTipText("");
jSpinner1.setModel(spinnerNumberModel);
jSpinner1.addChangeListener(new MainFrame_jSpinner1_ChangedAdapter(this));
jScrollPane1.setOpaque(false);
jDeepPanel.setAlignmentX( (float) 0.5);
jDeepPanel.setAlignmentY( (float) 0.5);
jList1.addListSelectionListener(new MainFrame_jList1_listSelectionAdapter(this));
this.getContentPane().add(jMainPanel, BorderLayout.CENTER);
jMainPanel.add(jSelectPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0
, GridBagConstraints.CENTER, GridBagConstraints.NORTH,
new Insets(0, 0, 0, 0), 240, 125));
jSelectPanel.add(jStartPanel, null);
jStartPanel.add(jLabel1, BorderLayout.NORTH);
jStartPanel.add(jDrawStartPanel, BorderLayout.CENTER);
jSelectPanel.add(jTargetPanel, null);
jTargetPanel.add(jLabel2, BorderLayout.NORTH);
jTargetPanel.add(jDrawTargetPanel, BorderLayout.CENTER);
jMainPanel.add(jDisplayPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0
, GridBagConstraints.CENTER, GridBagConstraints.NORTH,
new Insets(0, 0, 0, 0), 240, 250));
jDisplayPanel.add(jLabel3, BorderLayout.NORTH);
jDisplayPanel.add(jDrawDisplayPanel, BorderLayout.CENTER);
this.getContentPane().add(jDataPanel, BorderLayout.EAST);
jDeepPanel.add(jDepthRadioButton, null);
jDeepPanel.add(jSpinner1, null);
jOptionPanel.add(jBreadthRadioButton,
new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
, GridBagConstraints.NORTHWEST,
GridBagConstraints.NONE,
new Insets(4, 4, 0, 0), 0, 0));
jOptionPanel.add(jBSRadioButton,
new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
, GridBagConstraints.NORTHWEST,
GridBagConstraints.NONE,
new Insets(4, 4, 0, 0), 0, 0));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -