?? 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 + -