合并排序算法的演示
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<y.length;i++)
{
button[i] = new JButton(String.valueOf(y[i]));
button[i].setFont(f);
button[i].setBounds(70 * i,200,60,30);
con.add(button[i]);
}
for(int i = 0;i<y.length;i++)
{
x[i] = button[i];
}
// this.setSize(700, 500);
// this.setSize(900,500);
//this.setSize(1100,500);
this.setSize(1065,620);
con.setBackground(Color.gray); //设置窗体的颜色
this.validate();
this.setVisible(true);
// this.setResizable(false);
this.setResizable(true);
this.setDefaultCloseOperation(HIDE_ON_CLOSE);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getActionCommand().equals("生成数")) //如果响应的事件是生成数
{
int num;
for(int i=0;i < this.y.length;i++) //随机生成按钮上的数
{
num = (int)(Math.random()*70); //得到随机数
this.button[i].setForeground(Color.black);
this.button[i].setText(String.valueOf(num)); //将随机数赋值于的按钮
}
基于IIS的配置
想在宿舍通过局域网共享大批文件/文件夹吗?想在家通过网线就能实现文件互访吗?家庭组麻烦?那就教你一招win7里全新的功能——自己搭建FTP服务器!
首先,控制面板-程序-打开或关闭Windows功能,或者在开始菜单里搜索"打开或",弹出Windows功能窗口,勾选Internet信息服务下的FTP功能和Web管理工具,以此开启服务:
【注意:必须选中Web管理工具而且全部展开选中,否则仅仅开启FTP功能无法继续调用IIS管理器】