📄 frame4.java
字号:
package myjava;
import myjava.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
/**
* <p>Title: JAVA课程设计</p>
* <p>Description: 实习3</p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: 湖南农业大学</p>
* @author 温小林
* @version 1.0
*/
public class Frame4 extends JFrame {
JPanel contentPane;
XYLayout xYLayout1 = new XYLayout();
JLabel jLabel4 = new JLabel();
JLabel jLabel8 = new JLabel();
JButton jButton2 = new JButton();
JTextArea jTextArea2 = new JTextArea();
XYLayout xYLayout4 = new XYLayout();
JLabel jLabel1 = new JLabel();
JTextArea jTextArea5 = new JTextArea();
JLabel jLabel3 = new JLabel();
JPanel jPanel3 = new JPanel();
JTextArea jTextArea6 = new JTextArea();
JLabel jLabel2 = new JLabel();
JButton jButton1 = new JButton();
JTextArea jTextArea3 = new JTextArea();
JPanel jPanel2 = new JPanel();
JButton jButton3 = new JButton();
JTextArea jTextArea7 = new JTextArea();
JLabel jLabel9 = new JLabel();
JTextArea jTextArea4 = new JTextArea();
XYLayout xYLayout3 = new XYLayout();
JButton jButton6 = new JButton();
JButton jButton5 = new JButton();
JLabel jLabel11 = new JLabel();
JLabel jLabel7 = new JLabel();
JTextArea jTextArea1 = new JTextArea();
JPanel jPanel1 = new JPanel();
JTextField jTextField2 = new JTextField();
JButton jButton4 = new JButton();
JLabel jLabel6 = new JLabel();
XYLayout xYLayout2 = new XYLayout();
JLabel jLabel10 = new JLabel();
JTabbedPane jTabbedPane1 = new JTabbedPane();
JLabel jLabel5 = new JLabel();
JLabel jLabel12 = new JLabel();
JLabel jLabel13 = new JLabel();
JEditorPane jEditorPane1 = new JEditorPane();
JLabel jLabel14 = new JLabel();
//Construct the frame
public Frame4() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
jPanel3.setLayout(xYLayout4);
jLabel3.setText("....................................................................................................." +
".....................");
jTextArea5.setBorder(BorderFactory.createLineBorder(Color.black));
jTextArea5.setText("系统等待中。。。");
jLabel1.setText("请输入数组。并用“逗号”分开!");
jLabel1.setDisplayedMnemonic('0');
jLabel1.setRequestFocusEnabled(true);
jLabel1.setPreferredSize(new Dimension(159, 18));
jLabel1.setDoubleBuffered(false);
jLabel1.setFont(new java.awt.Font("Dialog", 0, 12));
jTextArea2.setText("系统等待中。。。");
jTextArea2.setBorder(BorderFactory.createLineBorder(Color.black));
jButton2.setFont(new java.awt.Font("Dialog", 0, 12));
jButton2.setActionCommand("确 定");
jButton2.setBorder(BorderFactory.createEtchedBorder());
jButton2.setText("退 出");
jButton2.addActionListener(new Frame4_jButton2_actionAdapter(this));
jLabel8.setText("请输入数组。并用“逗号”分开!");
jLabel8.setDisplayedMnemonic('0');
jLabel8.setRequestFocusEnabled(true);
jLabel8.setPreferredSize(new Dimension(159, 18));
jLabel8.setDoubleBuffered(false);
jLabel8.setFont(new java.awt.Font("Dialog", 0, 12));
jLabel4.setText("折半查找算法(先排序后查找)");
jLabel4.setToolTipText("");
jLabel4.setFont(new java.awt.Font("Dialog", 0, 12));
contentPane.setLayout(xYLayout1);
this.setLocale(java.util.Locale.getDefault());
this.setResizable(false);
this.setSize(new Dimension(417, 381));
this.setTitle("利用线程比较查找/排序算法的运行时间");
jTextArea6.setText("系统等待中。。。");
jTextArea6.setBorder(BorderFactory.createLineBorder(Color.black));
jLabel2.setFont(new java.awt.Font("Dialog", 0, 12));
jLabel2.setText("顺序排序算法");
jButton1.setFont(new java.awt.Font("Dialog", 0, 12));
jButton1.setBorder(BorderFactory.createEtchedBorder());
jButton1.setText("确 定");
jButton1.addActionListener(new Frame4_jButton1_actionAdapter(this));
jTextArea3.setText("系统等待中。。。");
jTextArea3.setBorder(BorderFactory.createLineBorder(Color.black));
jPanel2.setLayout(xYLayout3);
jButton3.setFont(new java.awt.Font("Dialog", 0, 12));
jButton3.setBorder(BorderFactory.createLineBorder(Color.black));
jButton3.setToolTipText("");
jButton3.setText("产生随机数");
jButton3.addActionListener(new Frame4_jButton3_actionAdapter(this));
jTextArea7.setBorder(BorderFactory.createLineBorder(Color.black));
jTextArea7.setText("12,45,36,68,29,17,10,32,30,10,50,96,48,67,30,41,43,48");
jLabel9.setText("....................................................................................................." +
".....................");
jTextArea4.setBorder(BorderFactory.createLineBorder(Color.black));
jTextArea4.setToolTipText("");
jTextArea4.setText("12,45,36,68,29,17,10,32,30,10,50,96,48,67,30,41,43,48");
jButton6.setText("产生随机数");
jButton6.addActionListener(new Frame4_jButton6_actionAdapter(this));
jButton6.setToolTipText("");
jButton6.setBorder(BorderFactory.createLineBorder(Color.black));
jButton6.setFont(new java.awt.Font("Dialog", 0, 12));
jButton5.setText("开 始");
jButton5.addActionListener(new Frame4_jButton5_actionAdapter(this));
jButton5.setBorder(BorderFactory.createEtchedBorder());
jButton5.setFont(new java.awt.Font("Dialog", 0, 12));
jLabel11.setFont(new java.awt.Font("Dialog", 0, 12));
jLabel11.setToolTipText("");
jLabel11.setText("选择排序法");
jLabel7.setFont(new java.awt.Font("Dialog", 0, 12));
jLabel7.setToolTipText("");
jLabel7.setText("快速排序法");
jTextArea1.setBackground(Color.white);
jTextArea1.setAlignmentX((float) 1.0);
jTextArea1.setAlignmentY((float) 1.0);
jTextArea1.setBorder(BorderFactory.createLineBorder(Color.black));
jTextArea1.setText("系统等待中。。。");
jTextArea1.setTabSize(8);
jPanel1.setFont(new java.awt.Font("Dialog", 0, 12));
jPanel1.setLayout(xYLayout2);
jTextField2.setFont(new java.awt.Font("Dialog", 0, 12));
jTextField2.setBorder(BorderFactory.createLineBorder(Color.black));
jTextField2.setText("");
jButton4.setBorder(BorderFactory.createEtchedBorder());
jButton4.setFont(new java.awt.Font("Dialog", 0, 12));
jButton4.setText("退 出");
jButton4.addActionListener(new Frame4_jButton4_actionAdapter(this));
jLabel6.setText("....................................................................................................." +
".....................");
jLabel10.setText("冒泡排序法");
jLabel10.setToolTipText("");
jLabel10.setFont(new java.awt.Font("Dialog", 0, 12));
jTabbedPane1.setFont(new java.awt.Font("Dialog", 0, 12));
jLabel5.setFont(new java.awt.Font("Dialog", 0, 12));
jLabel5.setPreferredSize(new Dimension(121, 16));
jLabel5.setRequestFocusEnabled(true);
jLabel5.setText("请输入您要查找的数字:");
jLabel12.setFont(new java.awt.Font("Dialog", 1, 18));
jLabel12.setText("利用线程比较查找/排序算法的运行时间");
jLabel13.setFont(new java.awt.Font("Dialog", 0, 12));
jLabel13.setText("制作:计算机10班 6号 温小林");
jEditorPane1.setBackground(SystemColor.inactiveCaptionBorder);
jEditorPane1.setFont(new java.awt.Font("Dialog", 0, 12));
jEditorPane1.setText(" __!__\n _____(_)_____" +
"\n ! ! !");
jLabel14.setText("....................................................................................................." +
".....................");
jTabbedPane1.add(jPanel1, "主界面");
jPanel1.add(jLabel12, new XYConstraints(23, 14, 341, 68));
jPanel1.add(jLabel13, new XYConstraints(207, 283, -1, -1));
jPanel1.add(jEditorPane1, new XYConstraints(132, 121, -1, 82));
jTabbedPane1.add(jPanel2, "查找算法");
jPanel2.add(jLabel4, new XYConstraints(13, 144, 326, 19));
jPanel2.add(jLabel2, new XYConstraints(13, 72, 184, 21));
jPanel2.add(jTextArea2, new XYConstraints(12, 164, 365, 49));
jPanel2.add(jLabel1, new XYConstraints(12, 12, 180, 20));
jPanel2.add(jLabel3, new XYConstraints(12, 56, 376, 13));
jPanel2.add(jTextArea1, new XYConstraints(12, 93, 367, 41));
jPanel2.add(jTextArea4, new XYConstraints(13, 34, 362, 22));
jPanel2.add(jButton3, new XYConstraints(272, 10, 104, 18));
jPanel2.add(jButton2, new XYConstraints(190, 275, 68, 22));
jPanel2.add(jButton1, new XYConstraints(108, 275, 68, 22));
jPanel2.add(jLabel5, new XYConstraints(89, 243, 137, 25));
jPanel2.add(jTextField2, new XYConstraints(223, 245, 55, 18));
jPanel2.add(jLabel14, new XYConstraints(12, 221, 376, 13));
jTabbedPane1.add(jPanel3, "排序算法");
jPanel3.add(jLabel6, new XYConstraints(10, 264, 376, 13));
jPanel3.add(jButton5, new XYConstraints(212, 282, 75, 25));
jPanel3.add(jButton4, new XYConstraints(300, 282, 75, 25));
jPanel3.add(jLabel8, new XYConstraints(11, 12, 180, 20));
jPanel3.add(jTextArea7, new XYConstraints(12, 32, 366, 22));
jPanel3.add(jLabel9, new XYConstraints(12, 57, 376, 13));
jPanel3.add(jLabel10, new XYConstraints(12, 74, 139, -1));
jPanel3.add(jTextArea6, new XYConstraints(12, 94, 363, 39));
jPanel3.add(jLabel7, new XYConstraints(12, 139, 139, -1));
jPanel3.add(jTextArea5, new XYConstraints(12, 159, 363, 39));
jPanel3.add(jLabel11, new XYConstraints(12, 205, 139, -1));
jPanel3.add(jTextArea3, new XYConstraints(12, 225, 363, 39));
jPanel3.add(jButton6, new XYConstraints(273, 12, 104, 18));
contentPane.add(jTabbedPane1, new XYConstraints(8, 7, 395, 341));
}
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
void jButton3_actionPerformed(ActionEvent e) {
jTextArea4.setText("");
int table[]=new int [20];
int i;
for(i=0;i<table.length;i++)
table[i]=(int)(Math.random()*100);
for(i=0;i<table.length;i++)
{
jTextArea4.append(table[i]+",");
}
}
void jButton1_actionPerformed(ActionEvent e) {
try
{
if (jTextField2.getText().equals("")) {
System.out.println("错误,你没有输入要查找的关键字");
}
else {
String str = jTextField2.getText();
jTextArea1.setText("");
jTextArea2.setText("");
find fd1 = new find(jTextArea4, jTextArea1, Integer.parseInt(str), 1);
fd1.start();
find fd2 = new find(jTextArea4, jTextArea2, Integer.parseInt(str), 2);
fd2.start();
}
}
catch(NumberFormatException er)
{
System.out.println("操作错误! ");
}
return;
}
void jButton2_actionPerformed(ActionEvent e) {
System.exit(0);
}
void jButton6_actionPerformed(ActionEvent e) {
jTextArea7.setText("");
int table[]=new int [20];
int i;
for(i=0;i<table.length;i++)
table[i]=(int)(Math.random()*100);
for(i=0;i<table.length;i++)
{
jTextArea7.append(table[i]+",");
}
}
void jButton5_actionPerformed(ActionEvent e) {
jTextArea6.setText("");
jTextArea5.setText("");
jTextArea3.setText("");
sort s1=new sort(jTextArea4,jTextArea6,1);
s1.start();
sort s2=new sort(jTextArea4,jTextArea5,2);
s2.start();
sort s3=new sort(jTextArea4,jTextArea3,3);
s3.start();
return;
}
void jButton4_actionPerformed(ActionEvent e) {
System.exit(0);
}
}
class Frame4_jButton3_actionAdapter implements java.awt.event.ActionListener {
Frame4 adaptee;
Frame4_jButton3_actionAdapter(Frame4 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton3_actionPerformed(e);
}
}
class Frame4_jButton1_actionAdapter implements java.awt.event.ActionListener {
Frame4 adaptee;
Frame4_jButton1_actionAdapter(Frame4 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
class Frame4_jButton2_actionAdapter implements java.awt.event.ActionListener {
Frame4 adaptee;
Frame4_jButton2_actionAdapter(Frame4 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
class Frame4_jButton6_actionAdapter implements java.awt.event.ActionListener {
Frame4 adaptee;
Frame4_jButton6_actionAdapter(Frame4 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton6_actionPerformed(e);
}
}
class Frame4_jButton5_actionAdapter implements java.awt.event.ActionListener {
Frame4 adaptee;
Frame4_jButton5_actionAdapter(Frame4 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton5_actionPerformed(e);
}
}
class Frame4_jButton4_actionAdapter implements java.awt.event.ActionListener {
Frame4 adaptee;
Frame4_jButton4_actionAdapter(Frame4 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton4_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -