Java聊天室毕业论文(6)

2019-04-23 13:07

河南理工大学本科生毕业设计(论文)说明书

toolBar.add(stopServer); toolBar.addSeparator(); toolBar.add(exitButton);

contentPane.add(toolBar,BorderLayout.NORTH); stopServer.setEnabled(false); stopItem.setEnabled(false); portItem.addActionListener(this); startItem.addActionListener(this); stopItem.addActionListener(this); exitItem.addActionListener(this); helpItem.addActionListener(this); portSet.addActionListener(this); startServer.addActionListener(this); stopServer.addActionListener(this); exitButton.addActionListener(this); combobox=new JComboBox(); combobox.insertItemAt(\所有人\ combobox.setSelectedIndex(0); messageShow=new JTextArea(); messageShow.setEditable(false); messageScrollPane=new

JScrollPane(messageShow,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); messageScrollPane.setPreferredSize(new Dimension(400,400)); messageScrollPane.revalidate(); showStatus=new JTextField(35); showStatus.setEditable(false);

21

河南理工大学本科生毕业设计(论文)说明书

sysMessage=new JTextField(23); sysMessage.setEnabled(false); sysMessageButton=new JButton(); sysMessageButton.setText(\发送\ sysMessage.addActionListener(this); sysMessageButton.addActionListener(this); sendToLabel=new JLabel(\发送至:\ messageLabel=new JLabel(\发送消息:\ downPanel=new JPanel(); gridBag=new GridBagLayout(); downPanel.setLayout(gridBag); gridBagCon=new GridBagConstraints(); gridBagCon.gridx=0; gridBagCon.gridy=0; gridBagCon.gridwidth=3; gridBagCon.gridheight=2; gridBagCon.ipadx=5; gridBagCon.ipady=5;

JLabel none=new JLabel(\ \ gridBag.setConstraints(none,gridBagCon); downPanel.add(none);

gridBagCon=new GridBagConstraints(); gridBagCon.gridx=0; gridBagCon.gridy=2;

gridBagCon.insets=new Insets(1,0,0,0); gridBagCon.ipadx=5; gridBagCon.ipady=5;

22

河南理工大学本科生毕业设计(论文)说明书

gridBag.setConstraints(sendToLabel,gridBagCon); downPanel.add(sendToLabel);

gridBagCon=new GridBagConstraints(); gridBagCon.gridx=1; gridBagCon.gridy=2;

gridBagCon.anchor=GridBagConstraints.LINE_START; gridBag.setConstraints(combobox,gridBagCon); downPanel.add(combobox);

gridBagCon=new GridBagConstraints(); gridBagCon.gridx=0; gridBagCon.gridy=3;

gridBag.setConstraints(messageLabel,gridBagCon); downPanel.add(messageLabel); gridBagCon=new GridBagConstraints(); gridBagCon.gridx=1; gridBagCon.gridy=3;

gridBag.setConstraints(sysMessage,gridBagCon); downPanel.add(sysMessage);

gridBagCon=new GridBagConstraints(); gridBagCon.gridx=2; gridBagCon.gridy=3;

gridBag.setConstraints(sysMessageButton,gridBagCon); downPanel.add(sysMessageButton); gridBagCon=new GridBagConstraints(); gridBagCon.gridx=0; gridBagCon.gridy=4; gridBagCon.gridwidth=3;

23

河南理工大学本科生毕业设计(论文)说明书

gridBag.setConstraints(showStatus,gridBagCon); downPanel.add(showStatus);

contentPane.add(messageScrollPane,BorderLayout.CENTER); contentPane.add(downPanel,BorderLayout.SOUTH); this.addWindowListener( new WindowAdapter(){

public void windowClosing(WindowEvent e){ stopService(); System.exit(0); } } ); } /**

* 事件处理 */

public void actionPerformed(ActionEvent e) { Object obj=e.getSource();

if (obj==startServer || obj==startItem) { startService(); }

else if(obj==stopServer || obj==stopItem) {

int j=JOptionPane.showConfirmDialog(this,\真的停止服务吗?\停止服务\ if(j==JOptionPane.YES_OPTION) { stopService(); }

24

河南理工大学本科生毕业设计(论文)说明书

}

else if(obj==portSet||obj==portItem) { PortConf portConf=new PortConf(this); //portConf.show(); portConf.setVisible(true); }

else if (obj==exitButton||obj==exitItem) {

int j=JOptionPane.showConfirmDialog(this,\真的要退出吗?\退出\ if(j==JOptionPane.YES_OPTION) { stopService(); System.exit(0); } }

else if(obj==helpItem){

Help helpDialog=new Help(this); helpDialog.setVisible(true); }

else if (obj==sysMessage || obj==sysMessageButton){ sendSystemMessage(); } }

public void startService(){ try{

serverSocket=new ServerSocket(port,10);

messageShow.append(\服务端已经启动,在\端口侦听...\\n\

startServer.setEnabled(false);

25


Java聊天室毕业论文(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:五年级Unit1第一课时导学案 - 图文

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: