📄 chatlogframe.java
字号:
/**
* ChatLogFrame.java
* Date 10:26 2006-4-2
*/
package com.herb.teacherclient;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class ChatLogFrame extends JFrame{
JLabel namelabel=new JLabel("选择登陆到那个专业讨论区:");
static JComboBox list=new JComboBox();
JPanel boxPanel=new JPanel();
JPanel textPanel=new JPanel();
JPanel btnPanel=new JPanel();
JButton okBtn=new JButton("登陆",new ImageIcon("com/herb/teacherclient/icons/ok.gif"));
JButton noBtn=new JButton("取消",new ImageIcon("com/herb/teacherclient/icons/dis.gif"));
static JTextField field;
JPanel fieldPanel=new JPanel();
private static final String CODE6="006"; // 获得某专业学生名
private static final String CODE7="007"; // 从服务器获得专业名
public ChatLogFrame(){
super("登陆设置");
ClientPart ct=new ClientPart(CODE7);
Thread th=new Thread(ct);
th.start();
boxPanel.add(list);
field=new JTextField(10);
list.setPreferredSize(new Dimension(200,20));
list.addItemListener(new ItemListener(){
public void itemStateChanged(ItemEvent e){
String chatTo=(String)list.getSelectedItem();
field.setText(chatTo);
}
});
textPanel.add(namelabel);
btnPanel.add(okBtn);
okBtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
if(field.getText().equals(""))
warn();
else{
dispose();
ChatFrame chatframe=new ChatFrame();
try{
Thread.sleep(20);
}catch(InterruptedException ex){
System.out.println("thread wrong!"+ex.getMessage());
}
ClientPart chat=new ClientPart(CODE6,field.getText());
Thread th=new Thread(chat);
th.start();
LocationSet.setFrameLocation(chatframe);
}
}
});
btnPanel.add(noBtn);
noBtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
dispose();
}
});
fieldPanel.add(new JLabel("登陆到:"));
fieldPanel.add(field);
JPanel panel=new JPanel();
panel.setLayout(new GridLayout(0,1));
panel.add(textPanel);
panel.add(boxPanel);
panel.add(fieldPanel);
panel.add(btnPanel);
getContentPane().setLayout(new BorderLayout(5,5));
getContentPane().add("Center",panel);
LocationSet.setFrameLocation(this);
pack();
show();
setResizable(false);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
dispose();
}
});
}
//初始化list
public static void initBox(Vector v){
if((list.getItemCount())!=0)
list.removeAllItems();
for(int i=0;i<v.size();i++)
list.addItem(v.elementAt(i));
}
public void warn(){
new MsgDialog(this,"不能为空!");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -