⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 serverboard.java

📁 花了一个月时间搞成的 很不错的一个面板 可作FTp的参考 实现文件上传下载及类似BBS的用户管理 查询
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
//package server;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
//import java.util.*;
class ServerBoard extends JFrame  implements ActionListener,ItemListener{
   Button   deleteFileButton, setCoinButton,setFreeButton,closeServerButton,setFileNameButton;
   Button  OKButton1,cancelButton1,OKButton2,cancelButton2,OKButton3,cancelButton3,warningButton;
   Label    welcomeLabel, userLabel,fileLabel,setCoinLabel,warningLabel;
   Label    setFreeLabel,deleteFileLabel,closeServerLabel;
   Label    fileNameLabel,fileCoinLabel,fileUploaderLabel;
   Label    userNameLabel,userMoneyLabel,userFileNumberLabel;
   Dialog   deleteFileDialog,setFreeDialog,closeServerDialog,warningDialog;
   JTextField setFileNameText;
   List     fileNameList, userNameList;
   TextField  fileCoinText,fileUploaderText,userMoneyText,userFileNumberText;
   JScrollPane  userScrollPane,fileScrollPane;
   JPanel    welcomePanel,filePanel,userPanel;
   JPanel    fileLabelPanel,fileOperationPanel,userLabelPanel;
   String[]  fileNameString,fileCoinString,fileUploaderString;
   String[]  userNameString,userMoneyString,userFileNumberString;
   String  fileNameNow;
	
   
   //用构造方法初始化
   public ServerBoard(){
	setTitle("虚拟社区系统服务器端");setSize(600,550);
	setLocation(140,100);
	setResizable(false);
        setFont(new Font("宋体",Font.PLAIN,14));
        addWindowListener(new WinAdptServer(this));
        
	Container contentPane=getContentPane();
	contentPane.setLayout(null);
	
	deleteFileButton=new      Button("删 除");
	setCoinButton=new         Button("设定价格");
	setFreeButton=new         Button("设为免费");
	closeServerButton=new     Button(" 关 闭 服 务 器 ");
	setFileNameButton=new     Button("更改文件名");
	OKButton1=new             Button("确  认");
	cancelButton1=new         Button("取  消");
	OKButton2=new             Button("确  认");
	cancelButton2=new         Button("取  消");
	OKButton3=new             Button("确  认");
	cancelButton3=new         Button("取  消");
	warningButton=new         Button("确  认");
	welcomeLabel=new          Label("  欢迎您使用东南大学虚拟社区系统  ");
	welcomeLabel.setForeground(new Color(150,150,200));
	welcomeLabel.setBackground(Color.green);
	userLabel=new             Label("用 户 列 表");
	fileLabel=new             Label("文 件 列 表");
	setCoinLabel=new          Label("价 格");
	setFreeLabel=new          Label("要设置成免费文件吗?");
	deleteFileLabel=new       Label("确认要删除所选文件吗?");
	closeServerLabel=new      Label(
	"确认要关闭东南大学虚拟社区服务器系统吗?如果关闭文件传输将会终止");
	closeServerLabel.setForeground(Color.red);
	fileNameLabel=new         Label("文  件  名   列  表");
	fileCoinLabel=new         Label("该  文  件  价  格");
	fileUploaderLabel=new     Label("该  文  件  上  传  者");
        userNameLabel=new         Label("用  户  名   列   表");
        userMoneyLabel=new        Label("社 区 财 富");
        userFileNumberLabel=new   Label("上传文件数量");
        warningLabel=new          Label("");
	deleteFileDialog =new     Dialog(this,"系 统 提 示",true);
	closeServerDialog=new     Dialog(this, "系 统 提 示",true);
	setFreeDialog=new         Dialog(this, "系 统 提 示",true);
	warningDialog=new         Dialog(this,"  系 统 提 示",true);
	setFileNameText=new           JTextField("未命名X",10);
	welcomePanel=new          JPanel();
	filePanel=new             JPanel();
	userPanel=new             JPanel();
	userLabelPanel=new        JPanel();
	fileLabelPanel=new        JPanel();
	fileOperationPanel=new    JPanel();
	fileNameList=new          List(10,false);
	fileCoinText=new          TextField(10);
	fileUploaderText=new      TextField(10);
	userNameList=new          List(10,false);
	userMoneyText=new         TextField(10);
	userFileNumberText=new    TextField(10);
	fileNameNow=new   String("");
	/*正式读取时
	for(int i=0;i<15;i++)
	fileNameString[i]=返回的文件名[i];*/
	fileNameString= new String[]{
	"Java general introduction05.ppt",
	"在新的形势下,加强党建带团建工作的调研与思考.doc",
	"东南大学吴健雄学院03级社会实践铁心桥办事处高家库村小组 宋洪磊  汪恺",
	"寄托狂的传说",
	"廖仲恺的夫人和宋子文",
	"周恩来青春年少",
	"青春万岁",
	"基地组织与布什家族",
	"魔兽战略",
	"我看美国",
	"哈哈哈哈",
	"中国万岁",
	"医院解剖室的月光",
	"长城保卫战",
	"大学自习室之东大版"};
	userNameString= new String[]{
	"gaomingchen",
	"tangziqiang",
	"luzhaopeng",
	"wangronghua",
	"songhonglei",
	"顾冠群",
	"哈里波特",
	"郑成功",
	 "刘德华",
	"JayChou",
	"JeffChou"};
	fileCoinString=new  String[]{
	"10","20","30","40","50","60","70","80","90","100","120","120","130","140","150"};
	fileUploaderString=new  String[]{
		userNameString[0],
		userNameString[1],
		userNameString[2],
		userNameString[3],
		userNameString[3],
		userNameString[5],
		userNameString[5],
		userNameString[7],
		userNameString[9],
		userNameString[10],
		userNameString[10],
		userNameString[6],
		userNameString[4],
		userNameString[2],
		userNameString[3]};
	userMoneyString=new  String[]{
		"3000","2000","5000","3000","4000","4000","9999","3333","1111","2333","4444"};
	userFileNumberString=new  String[]{
		"2","3","3","4","4","45","5","6","7","8","8"};
		

	for(int i=0;i<15;i++)
	fileNameList.add(fileNameString[i]);
	for(int i=0;i<10;i++)
	userNameList.add(userNameString[i]);

	//向welcomePanel添加内容和设置布局
	welcomePanel.add(welcomeLabel);
	welcomePanel.add(closeServerButton);
	welcomeLabel.setFont(new Font("宋体",Font.BOLD,16));
	welcomePanel.setLayout(null);
	welcomePanel.setBounds(15,10,300,35);
	welcomeLabel.setBounds(10,5,280,30);
	welcomePanel.setFont(new Font("GB2312",Font.PLAIN,14));
	closeServerButton.setBounds(355,5,100,28);

	
	//向文件面板添加内容和设置布局
	filePanel.setLayout(null);
	filePanel.add(fileNameLabel);
	filePanel.add(fileCoinLabel);
	filePanel.add(fileUploaderLabel);
	filePanel.add(fileNameList);
	filePanel.add(fileCoinText);
	filePanel.add(fileUploaderText);
	filePanel.setBounds(30,55,540,185);
	fileNameLabel.setBounds(10,10,150,20);
	fileCoinLabel.setBounds(320,35,150,25);
	fileUploaderLabel.setBounds(320,110,180,25);
	fileNameList.setBounds(15,35,280,150);
	fileCoinText.setBounds(320,65,200,30);
	fileUploaderText.setBounds(320,140,200,30);
	
	//向文件操作面板添加内容和设置布局
	fileOperationPanel.setLayout(null);
	fileOperationPanel.add(setCoinLabel);
	fileOperationPanel.add(setCoinButton);
	fileOperationPanel.add(setFileNameText);
	fileOperationPanel.add(deleteFileButton);
	fileOperationPanel.add(setFreeButton);
	fileOperationPanel.add(setFileNameButton);
	fileOperationPanel.setBounds(30,260,530,30);
	setFileNameButton.setBounds(10,5,70,25);
	setFileNameText.setBounds(85,5,150,25);
	setCoinButton.setBounds(250,5,60,25);
	setFreeButton.setBounds(335,5,60,25);
	deleteFileButton.setBounds( 415,5,60,25);
	
	//向用户面板添加内容和设置布局
	 userPanel.setLayout(null);
	 userPanel.add(userNameLabel);
	 userPanel.add(userMoneyLabel);
	 userPanel.add(userFileNumberLabel);
	 userPanel.add(userNameList);
	 userPanel.add(userMoneyText);
	 userPanel.add(userFileNumberText);
	 userPanel.setBounds(30,310,540,200);
	 userNameLabel.setBounds(10,10,150,20);
	 userMoneyLabel.setBounds(320,35,100,25);
	 userFileNumberLabel.setBounds(320,110,140,25);
	 userNameList.setBounds(15,35,280,145);
	 userMoneyText.setBounds(320,65,180,30);
	 userFileNumberText.setBounds(320,140,180,30);
	 
	 
	//向关闭服务器对话框添加内容和设置布局
	closeServerDialog.add(closeServerLabel);
	closeServerDialog.add(OKButton1);
	closeServerDialog.add(cancelButton1);
	closeServerDialog.setLayout(null);
	closeServerLabel.setBounds(20,35,445,30);
	OKButton1.setBounds(145,85,45,25);
	cancelButton1.setBounds(245,85,45,25);
	
	//向删除文件对话框添加内容和设置布局
	deleteFileDialog.add(deleteFileLabel);
	deleteFileDialog.add(OKButton2);
	deleteFileDialog.add(cancelButton2);
	deleteFileDialog.setLayout(null);
	deleteFileLabel.setBounds(68,35,220,30);
	OKButton2.setBounds(75,90,45,25);
	cancelButton2.setBounds(140,90,45,25);
	
	//向设置免费对话框添加内容和设置布局
	setFreeDialog.add(setFreeLabel);
	setFreeDialog.add(OKButton3);
	setFreeDialog.add(cancelButton3);
	setFreeDialog.setLayout(null);
	setFreeLabel.setBounds(68,35,220,30);
	OKButton3.setBounds(75,90,45,25);
	cancelButton3.setBounds(140,90,45,25);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -