河南理工大学本科生毕业设计(论文)说明书
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
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库Java聊天室毕业论文(6)在线全文阅读。
相关推荐: