📄 frame1.java~14~
字号:
package yerenchengxu;import java.io.*;import java.util.*;import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.event.*;import com.borland.jbcl.layout.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: </p> * @author unascribed * @version 1.0 */public class Frame1 extends JFrame { private JPanel contentPane; private JMenuBar jMenuBar1 = new JMenuBar(); private JMenu jMenuFile = new JMenu(); private JMenuItem jMenuFileExit = new JMenuItem(); private JMenu jMenuHelp = new JMenu(); private JMenuItem jMenuHelpAbout = new JMenuItem(); private JToolBar jToolBar = new JToolBar(); private JButton jButton1 = new JButton(); private JButton jButton2 = new JButton(); private JButton jButton3 = new JButton(); private ImageIcon image1; private ImageIcon image2; private ImageIcon image3; private JLabel statusBar = new JLabel(); private XYLayout xYLayout1 = new XYLayout(); private JPanel jPanel1 = new JPanel(); private JPanel jPanel2 = new JPanel(); private XYLayout xYLayout2 = new XYLayout(); private XYLayout xYLayout3 = new XYLayout(); private JTextArea jTextArea1 = new JTextArea(); private JTextArea jTextArea2 = new JTextArea(); private String temp1; private String temp2; private JButton jButton4 = new JButton(); //Construct the frame public Frame1() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { image1 = new ImageIcon(yerenchengxu.Frame1.class.getResource("openFile.gif")); image2 = new ImageIcon(yerenchengxu.Frame1.class.getResource("closeFile.gif")); image3 = new ImageIcon(yerenchengxu.Frame1.class.getResource("help.gif")); //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]"))); contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(xYLayout1); this.setSize(new Dimension(400, 300)); this.setTitle("yeren chengxu"); statusBar.setText(" "); jMenuFile.setText("File"); jMenuFileExit.setText("Exit"); jMenuFileExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jMenuFileExit_actionPerformed(e); } }); jMenuHelp.setText("Help"); jMenuHelpAbout.setText("About"); jMenuHelpAbout.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jMenuHelpAbout_actionPerformed(e); } }); jButton1.setIcon(image1); jButton1.setToolTipText("Open File"); jButton2.setIcon(image2); jButton2.setToolTipText("Close File"); jButton3.setIcon(image3); jButton3.setToolTipText("Help"); jPanel1.setLayout(xYLayout2); jPanel2.setLayout(xYLayout3); jButton4.setText("最佳路径"); jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton4_actionPerformed(e); } }); jToolBar.add(jButton1); jToolBar.add(jButton2); jToolBar.add(jButton3); jMenuFile.add(jMenuFileExit); jMenuHelp.add(jMenuHelpAbout); jMenuBar1.add(jMenuFile); jMenuBar1.add(jMenuHelp); this.setJMenuBar(jMenuBar1); contentPane.add(jToolBar, new XYConstraints(0, 0, 400, -1)); contentPane.add(statusBar, new XYConstraints(0, 282, 400, -1)); contentPane.add(jPanel1, new XYConstraints(20, 35, 136, 258)); jPanel1.add(jTextArea1, new XYConstraints(0, 0, 150, 228)); contentPane.add(jPanel2, new XYConstraints(248, 33, 147, 243)); jPanel2.add(jTextArea2, new XYConstraints(0, 0, 138, 226)); contentPane.add(jButton4, new XYConstraints(164, 117, -1, 39)); temp1=" 初始状态:\n"; temp1+=" (3,3,1)\n"+" 说明:\n 第一个 3 代表:\n 左岸有三个修道士;\n"+" 第二个 3 代表:\n 左岸有三个野人;\n"+" 1 代表船在左岸"; jTextArea1.setText(temp1); temp2=" 目标状态:\n"; temp2+=" (0,0,0)\n"+" 说明:\n 第一个 0 代表:\n 左岸有0个修道士;\n"+" 第二个 0 代表:\n 左岸有0个野人;\n"+" 第三个 0 代表:\n 船在右岸"; jTextArea2.setText(temp2); } //File | Exit action performed public void jMenuFileExit_actionPerformed(ActionEvent e) { System.exit(0); } //Help | About action performed public void jMenuHelpAbout_actionPerformed(ActionEvent e) { Frame1_AboutBox dlg = new Frame1_AboutBox(this); Dimension dlgSize = dlg.getPreferredSize(); Dimension frmSize = getSize(); Point loc = getLocation(); dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); dlg.setModal(true); dlg.pack(); dlg.show(); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { jMenuFileExit_actionPerformed(null); } } void jButton4_actionPerformed(ActionEvent e) { Vector finalresult=new Vector(); SearchProcess searchprocess=new SearchProcess(); finalresult=searchprocess.success(); Frame2 frame2=new Frame2(finalresult); frame2.show(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -