合并排序算法的演示

时间:2015-11-25 01:07:15
【文件属性】:
文件名称:合并排序算法的演示
文件大小:14KB
文件格式:RAR
更新时间:2015-11-25 01:07:15
合并排序演示 import java.awt.Color; import java.awt.Container; import java.awt.Font; import java.awt.Scrollbar; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.FileInputStream; import java.io.FileOutputStream; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Timer; import java.util.TimerTask; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JScrollBar; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.Scrollable; class SortWindow extends JFrame implements ActionListener //定义一个排序窗口类 { PaiXu px; //声明一个排序的对象 JButton start; //开始演示 JButton go; //继续演示 JButton suspend; //暂停 JButton end; //结束程序的播放,终止 JButton tuichu; //退出 Container con; JButton randomNumber; //用于产生待排序的随机数 int y[] = {0,0,0,0,0,0,0,0,0,0}; //用于按钮的初值 JButton[] x; JLabel title; //演示程序的标题 JButton button[]; JButton tempBtn[]; //按钮的中间变量,用于扭的设置 JTextArea mul; //用于算法演示 的说明信息 JTextArea ta; //显示动画排序的关键代码 JScrollPane sp; FileOutputStream fos ; FileInputStream fis; public SortWindow(String s) { px = new PaiXu(this); this.setTitle(s); x = new JButton[y.length]; Font f=new Font("新宋体",Font.BOLD,20); con = getContentPane(); con.setLayout(null); title = new JLabel("合并排序算法演示的课程设计。。。"); //title.setForeground(Color.red); title.setForeground(Color.blue); title.setFont(new Font("新宋体",Font.BOLD,40)); title.setBounds(70,100,600,40); //title.setBounds(30,50,600,40); con.add(title); mul = new JTextArea(); mul.setBounds(0, 470, 200,100); mul.setBackground(Color.gray); StringBuffer sb = new StringBuffer(); sb.append("注意:").append("\n"); sb.append("黑色表示生成的数").append("\n"); sb.append("红色表示两个数比较的位置").append("\n"); sb.append("绿色表示比比较的数小").append("\n"); sb.append("蓝色表示以排好了序的数").append("\n"); mul.setText(sb.toString()); mul.setForeground(Color.red); mul.setEditable(false); con.add(mul); ta = new JTextArea(); //shows用于显示关键的排序代码 ta.setVisible(true); ta.setEditable(false); //设置文本框为不可编辑 ta.setBackground(Color.yellow); //将ta的背景设置为黄色 sp = new JScrollPane(ta); sp.setLocation(690, 0); sp.setSize(350, 580); sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);//设置水平滚动条总是显示 sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); //设置垂直滚动条总是显示 con.add(sp); //shows.setFont(f); // shows.setBounds(700,130,400,360); // shows.setBounds(700,0,400,900); /////////////////////////////// // shows.setBounds(700,0,400,600); // shows.setCaretPosition(shows.getDocument().getLength()); // con.add(shows); randomNumber = new JButton("生成数"); randomNumber.setFont(f); // randomNumber.setBounds(50,400,110,30); randomNumber.setBounds(0,400,100,30); con.add(randomNumber); randomNumber.addActionListener(this); start = new JButton("开始"); start.setFont(f); // start.setBounds(200, 400, 80, 30); start.setBounds(120,400,80,30); con.add(start); start.addActionListener(this); /////////// go = new JButton("继续"); go.setFont(f); //go.setBounds(330,400,80,30); go.setBounds(220,400,80,30); con.add(go); go.addActionListener(this); //////// suspend = new JButton("暂停"); suspend.setFont(f); // suspend.setBounds(460,400,80,30); suspend.setBounds(320,400,80,30); con.add(suspend); suspend.addActionListener(this); end = new JButton("终止"); end.setFont(f); //end.setBounds(590, 400, 80, 30); end.setBounds(420,400,80,30); con.add(end); end.addActionListener(this); tuichu = new JButton("退出"); tuichu.setFont(f); //tuichu.setBounds(720,400,80,30); tuichu.setBounds(520,400,80,30); con.add(tuichu); tuichu.addActionListener(this); button = new JButton[y.length]; SortCode(); //显示动画排序的代码 for(int i = 0;i 立即下载

【文件预览】:
合并排序算法演示
----.project(400B)
----bin()
--------com()
----.settings()
--------org.eclipse.jdt.core.prefs(598B)
----1.txt(0B)
----src()
--------com()
----.classpath(301B)

网友评论