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

📄 clientboard.java

📁 花了一个月时间搞成的 很不错的一个面板 可作FTp的参考 实现文件上传下载及类似BBS的用户管理 查询
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
//packet Client
/*该包程序中所有类单词首字母大写,所有成员变量和方法首字母小写其后大写
,所有局部变量首字母小写*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
//import java.util.*;
class ClientBoard extends JFrame  implements ActionListener,TextListener,ItemListener
{
	
boolean ONLINE;
Button changeUserButton,newUserButton;
Button loginButton,quitButton,changePasswordButton,addCoinButton;
Button searchFileButton,searchUserButton,upLoadButton,downLoadButton;
Button OKButton1,cancelButton1,OKButton2,cancelButton2,OKButton3,cancelButton3;
Button OKButton4,OKButton5,cancelButton5,OKButton6,resetButton,cancelButton6;
Button OKButton7,cancelButton7;
MenuBar  myMenuBar;
Menu  fileMenu; 
MenuItem quitItem,closeWindowItem,changePasswordItem,changeUserItem,systemInformationItem;
PopupMenu popMenu;
String userName, userMoney,userTime,userFileNumber,warningString,fileCoinString;
String[] userOnlineStringt,userFileString,fileInserverStringUp,fileInserverStringDown;
Label  userNameLabel,userMoneyLabel,userTimeLabel;
Label  userFileLabel,fileCoinLabel1,fileCoinLabel2;
Label  coinCardNumberInLabel,oldPasswordLabel,newPasswordLabel1,newPasswordLabel2;
Label  passwordInLabel,nameInLabel,quitLabel,warningTextLabel;
Label  newUserNameLabel,newUserPasswordLabel1,newUserPasswordLabel2;
Label  userOnlineLabel,fileOnlineLabel,welcomeLabel,warningLabel;
Label  newUserReadLabel1,newUserReadLabel2,newUserReadLabel3,newUserReadLabel4;
Label  newUserReadLabel5,newUserReadLabel6,newUserReadLabel7,newUserReadLabel8;
Label  newUserReadLabel9,newUserReadLabel10,newUserReadLabel11,newUserReadLabel12;;
TextField searchUserText,searchFileText,coinCardNumberText,userFileText;
TextField warningText;
JTextField userNameText,newUserNameText,downLoadText;
JPasswordField userPasswordText,oldPasswordText,newPasswordText1,newPasswordText2;
JPasswordField newUserPasswordText1,newUserPasswordText2;
List  userOnlineList,fileInserverListUp,fileInserverListDown,userFileList;
Dialog    loginDialog,newUserDialog,changePasswordDialog,addCoinDialog;
Dialog    newUserReadDialog,warningDialog,quitDialog;
FileDialog  fileDialogLoad,fileDialogSave;
JPanel userInformationPanel,loginPanel,oprationPanel,userPanel,filePanel;
JScrollPane  userScrollPane,fileScrollPane,warningScrollPane;
public ClientBoard(){
	setTitle("虚拟社区系统客户端");
	setSize(666,600);
	setLocation(140,100);
	setResizable(false);
        //setVisible(false);
        setFont(new Font("宋体",Font.PLAIN,14));
        addWindowListener(new WinAdptClient(this));
        
	Container contentPane=getContentPane();
	contentPane.setLayout(null);
	
	ONLINE=false;
	//对按扭初始化
	loginButton=new      Button("登录");
	changeUserButton=new Button("更换用户");
	quitButton=new       Button("离线");
	changePasswordButton=new Button("更改密码");
	addCoinButton=new    Button("我要充值");
	searchFileButton=new Button("查找文件");
	searchUserButton=new Button("查找用户");
	upLoadButton=new     Button("上传文件");
	downLoadButton= new  Button("下载文件 ");
	newUserButton=new    Button("我要注册");
	
	OKButton1=new Button("确 认");cancelButton1=new Button("取 消");
	OKButton2=new Button("确 认");cancelButton2=new Button("取 消");
	OKButton3=new Button("确 认");cancelButton3=new Button("取 消");
	OKButton4=new Button("确 认");resetButton=new   Button("重  置");
	OKButton5=new Button("确   认");cancelButton5=new  Button("取   消");
	OKButton6=new Button("注  册");cancelButton6=new   Button("取  消");
	OKButton7=new Button("我 同 意");cancelButton7=new Button("不 同 意");
	loginButton.setForeground(Color.blue);
	quitButton.setForeground(Color.blue);
	changeUserButton.setForeground(Color.blue);
	//string初始化
	userName="****";
	userMoney="8888";
	userTime="9999";
	fileCoinString="0";
	userFileNumber="213";
	warningString=new String(
	   "本系统1.0版本由seu09公司高明辰、唐自强、卢兆鹏、王荣华、宋洪磊编制.");
	
	//对菜单初始化
	myMenuBar=new MenuBar();
	fileMenu=new Menu("系统选项");
	systemInformationItem=new MenuItem("系统信息");
	quitItem=new MenuItem("离线",new MenuShortcut('w'));
	 closeWindowItem=new MenuItem ("关闭窗口",new MenuShortcut('u'));
	changePasswordItem=new MenuItem("更改密码",new MenuShortcut('q'));
	changeUserItem=new MenuItem("更改用户",new MenuShortcut('t'));
	fileMenu.add(systemInformationItem);
	fileMenu.add(changePasswordItem); 
	fileMenu.add(changeUserItem);
	fileMenu.add(quitItem);
	fileMenu.addSeparator();
	fileMenu.add(closeWindowItem);
	myMenuBar.add(fileMenu);
	setMenuBar(myMenuBar);
	//对右键初始化
	/*popMenu=new PopupMenu();
	popMenu.add(changePasswordItem);
	popMenu.add(changeUserItem);
	popMenu.add(quitItem);
	popMenu.addSeparator();
	popMenu.add(closeWindowItem);*/
	//对标签初始化
	warningTextLabel=new    Label("系统提示");
	userNameLabel =new  Label("在线用户:"+userName);
	userMoneyLabel=new  Label("您的金钱:"+userMoney+"贝");
	userTimeLabel =new  Label("在线时间:"+userTime+"分");
	nameInLabel   =new  Label("用户名");
	passwordInLabel=new Label("密  码  ");
	userFileLabel=new   Label("上传的所有文件如下:");
	fileCoinLabel1=new  Label("此文件价格为");
	fileCoinLabel2=new  Label("   "+fileCoinString+"    "+"贝");
	fileCoinLabel2.setForeground(Color.red);
	userNameLabel.setForeground(Color.red);
	userMoneyLabel.setForeground(Color.red);
	userTimeLabel.setForeground(Color.red);
	coinCardNumberInLabel=new Label("请输入充值卡号码");
	oldPasswordLabel=new  Label("请输入旧密码");
	newPasswordLabel1=new Label("请输入新密码");
	newPasswordLabel2=new Label("请确认新密码");
	userOnlineLabel=new   Label("当前在线用户");
	fileOnlineLabel=new   Label("当前文件列表");
	newUserNameLabel=new  Label("请输入登录用户名");
	newUserPasswordLabel1=new Label(" 请输入登录密码  ");
	newUserPasswordLabel2=new Label(" 请确认登录密码  ");
	warningLabel=new      Label(warningString);
	quitLabel=new         Label("您 真 的 要 退 出 社 区 吗?");
	quitLabel.setForeground(Color.red);
	welcomeLabel=new      Label("   欢迎您使用东南大学虚拟社区系统");
	welcomeLabel.setForeground(new Color(150,150,200));
	welcomeLabel.setBackground(Color.green);
	newUserReadLabel1=new  Label(
	"欢迎您加入东南大学虚拟社区系统参加交流和讨论");
	newUserReadLabel2=new  Label("本社区为公共社区,为维护网上公共秩序和社会稳定,请您自觉遵守以下条款:"); 
        newUserReadLabel3=new  Label(
        "(一)不得煽动抗拒、破坏宪法和法律、行政法规实施;");
        newUserReadLabel4=new  Label(
        "(二)不得煽动颠覆国家政权,推翻社会主义制度;");
        newUserReadLabel5=new  Label(
        "(三)不得煽动分裂国家、破坏国家统一的;");
        newUserReadLabel6=new  Label(
        "(四)不得煽动民族仇恨、民族歧视,破坏民族团结;");
        newUserReadLabel7=new  Label(
        "(五)不得捏造或者歪曲事实,散布谣言,扰乱社会秩序;");
        newUserReadLabel8=new  Label(
        "(六)不得宣扬封建迷信、淫秽、色情、赌博、暴力、凶杀、恐怖、教唆犯罪;");
        newUserReadLabel9=new  Label(
        "(七)不得公然侮辱他人或者捏造事实诽谤他人的,或者进行其他恶意攻击;");
        newUserReadLabel10=new Label(
        "(八)不得损害国家机关信誉;");
        newUserReadLabel11=new Label(
        "(九)不得其他违反宪法和法律行政法规;");
        newUserReadLabel12=new Label(
        "(十)不得进行商业广告行为。" );


	//对文本域初始化
	coinCardNumberText=new TextField(16);//充值卡号码设定为16位
	searchUserText=new     TextField(10);
	searchFileText=new     TextField(20);//文件名超过20不支持
	userFileText=new       TextField(userName,10);
	userPasswordText=new   JPasswordField(null,10);
	oldPasswordText=new    JPasswordField(null,10);
	newPasswordText1=new   JPasswordField(null,10);
	newPasswordText2=new   JPasswordField(null,10);
	newUserPasswordText1=new JPasswordField(null,10);
	newUserPasswordText2=new JPasswordField(null,10);
	userNameText=new         JTextField(10);
	newUserNameText=new      JTextField(10);
	warningText=new          TextField(warningString);
	downLoadText=new         JTextField(30);
	
	//对密码域初始化
	userPasswordText.setEchoChar('*');
	oldPasswordText.setEchoChar('*');
	newPasswordText1.setEchoChar('*');
	newPasswordText2.setEchoChar('*');
	
	//对列表初始化
	userOnlineList=new       List(9,false);
	fileInserverListUp=new   List(7,false);
	fileInserverListDown=new List(7,false);
	userFileList=new         List(5,false);
        
        //以下列表添家的方法属于测试用例,正式操作时调用专门的复制方法listContent
        //添加列表选项
	userOnlineList.add("gaomingchen");
	userOnlineList.add("tangziqiang");
	userOnlineList.add("luzhaopeng");
	userOnlineList.add("wangronghua");
	userOnlineList.add("songhonglei");
	userOnlineList.add("顾冠群");
	userOnlineList.add("哈里波特");
	userOnlineList.add("郑成功");
	userOnlineList.add( "刘德华");
	userOnlineList.add("JayChou");
	userOnlineList.add("JeffChou");
	userOnlineList.add("");
	fileInserverListUp.add("Java general introduction05.ppt");
	fileInserverListUp.add("在新的形势下,加强党建带团建工作的调研与思考.doc");
	fileInserverListUp.add("东南大学吴健雄学院03级社会实践铁心桥办事处高家库村小组 宋洪磊  汪恺");
	fileInserverListUp.add("寄托狂的传说");
	fileInserverListUp.add("廖仲恺的夫人和宋子文");
	fileInserverListUp.add("周恩来青春年少");
	fileInserverListUp.add("青春万岁");
	fileInserverListUp.add("基地组织与布什家族");
	fileInserverListUp.add("魔兽战略");
	fileInserverListUp.add("我看美国");
	fileInserverListUp.add("哈哈哈哈");
	fileInserverListUp.add("中国万岁");
	fileInserverListUp.add("医院解剖室的月光");
	fileInserverListUp.add("长城保卫战");
	fileInserverListUp.add("大学自习室之东大版");
	fileInserverListDown.add("魔兽战略");
	fileInserverListDown.add("我看美国");
	fileInserverListDown.add("哈哈哈哈");
	fileInserverListDown.add("中国万岁");
	fileInserverListDown.add("医院解剖室的月光");
	fileInserverListDown.add("长城保卫战");
	fileInserverListDown.add("大学自习室之东大版");
	fileInserverListDown.add("基地组织与布什家族");
	fileInserverListDown.add("青春万岁");
	fileInserverListDown.add("周恩来青春年少");
	fileInserverListDown.add("廖仲恺的夫人和宋子文");
        fileInserverListDown.add("寄托狂的传说"); 
        fileInserverListDown.add("东南大学吴健雄学院03级社会实践铁心桥办事处高家库村小组 宋洪磊  汪恺");
	fileInserverListDown.add("在新的形势下,加强党建带团建工作的调研与思考.doc");
	fileInserverListUp.add("Java general introduction05.ppt");
	
	//对对话框和面板初始化
	loginDialog=new       Dialog(this,   "登录对话框",true);
	changePasswordDialog=new Dialog(this,"更改密码对话框",true);
	addCoinDialog=new     Dialog(this,   "充值对话框",true);
	warningDialog= new    Dialog(this,   "系 统 提 示",true);
	quitDialog=new        Dialog(this,   "        ",true);
	newUserDialog=new     Dialog(this,   "注册新用户",true);
	newUserReadDialog=new Dialog(this,   "继续注册前请先阅读我们的条款和协议声明",true);
	fileDialogLoad =new FileDialog(this,"请选择您要上传的文件",FileDialog.LOAD);
	fileDialogSave=new  FileDialog(this,"请选择您要保存的位置",FileDialog.SAVE);
	userInformationPanel=new JPanel();
	loginPanel=new        JPanel();
	oprationPanel=new     JPanel();
	userPanel=new         JPanel();
	filePanel =new        JPanel();
	
	//向用户列表和文件列表面板添加内容和设置布局
	userPanel.add(userOnlineList);
	userPanel.add(userFileList);
	userPanel.add(userFileText);
	userPanel.add(userFileLabel);
	filePanel.add(fileInserverListUp);
	filePanel.add(fileInserverListDown);
	filePanel.add(fileCoinLabel1);
	filePanel.add(fileCoinLabel2);
	userPanel.setLayout(null);
	filePanel.setLayout(null);
	fileInserverListUp.setBounds(145,100,240,205);
	fileInserverListDown.setBounds(145,325,240,200);
	fileCoinLabel1.setBounds(160,310,60,15);
	fileCoinLabel2.setBounds(222,310,45,15);
	
        userOnlineList.setBounds(395,100,240,270);
        userFileText.setBounds(395,380,60,20);
        userFileLabel.setBounds(460,380,200,20);
        userFileList.setBounds(395,405,240,120);
	userScrollPane=new  JScrollPane(userPanel,
	                                       ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
	                                       ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	                                       
	fileScrollPane=new  JScrollPane(filePanel,
	                                      ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
	                                      ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	//warningScrollPane=new JScrollPane(warningText,
	 //                                 ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
	                             //  ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);   
        //
	//对登陆面板添加内容和设置布局
	loginPanel.setLayout( null);
       	loginPanel.setFont(new Font("GB2312",Font.PLAIN,13));
	loginPanel.add(loginButton);
	loginButton.setBounds(280,6,60,24);
	loginPanel.add(changeUserButton);
	changeUserButton.setBounds(370,6,70,24);
	loginPanel.add(quitButton);
	quitButton.setBounds(470,6,60,24);
	loginPanel.add(warningText);
	loginPanel.add(warningTextLabel);
	warningTextLabel.setBounds(103,45,60,20);
	warningText.setBounds(170,45,380,20);
	loginPanel.add(userOnlineLabel);
	userOnlineLabel.setBounds(353,75,100,20);
	loginPanel.add(fileOnlineLabel);
	fileOnlineLabel.setBounds(103,75,100,20);
	loginPanel.add(welcomeLabel);
	welcomeLabel.setBounds(10,8,220,20);
	loginPanel.setBounds(90,0,550,55);
	
	//对用户信息面板添加内容和设置布局
	userInformationPanel.add(userNameLabel);
	userNameLabel.setBounds(15,53,50,20);
	userInformationPanel.add(userMoneyLabel);
	userMoneyLabel.setBounds(15,73,50,20);
	userInformationPanel.add(userTimeLabel);
	userTimeLabel.setBounds(15,93,50,20);
	userInformationPanel.setBounds(35,35,55,115);

⌨️ 快捷键说明

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