62,635
社区成员




package c_port_packageBJTeacher;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.GridLayout;
import java.awt.Rectangle;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class CardLayoutWindow extends JFrame implements WindowListener{
/**
*
*/
private static final long serialVersionUID = 1L;
static MyLog mainnum = new MyLog(0);
ArrayList<ArrayList<String>> chatword = new ArrayList<ArrayList<String>>();
static JPanel cards;
static String LocalMySocketData = "";
static HashMap<Integer,Boolean> myMemWorkNum = new HashMap<Integer,Boolean>();
static HashMap<Integer,Boolean> myDutyWorkNum = new HashMap<Integer,Boolean>();
static CardLayout a = new CardLayout();
int _width = 330;
int _height = 150;
int startYPosition = 0;
int stopYPosition = 0;
static MyLog nowJPanelnum = new MyLog(0);//本端点所接订单编号;
static String Chatword = "";
static public HashMap<Integer,JPanel> JPCollectionTeacher = new HashMap<Integer,JPanel>();
static public HashMap<Integer,JPanel> JPCollectioncustomer = new HashMap<Integer,JPanel>();
static public HashMap<Integer,ArrayList<String>> hashTeacher = new HashMap<Integer,ArrayList<String>>();
static public HashMap<Integer,ArrayList<String>> hashcustomer = new HashMap<Integer,ArrayList<String>>();
static public HashMap<String,MyFriendDS> todaymyfriendDS = new HashMap<String,MyFriendDS>();
String MyLocalSocketData = "";
static String MyFriendrole = "";
String MyFriChatWord = "";
ArrayList<String> al0 = new ArrayList<String>();
ArrayList<String> al1 = new ArrayList<String>();
ArrayList<String> al2 = new ArrayList<String>();
ArrayList<String> al3 = new ArrayList<String>();
ArrayList<String> al4 = new ArrayList<String>();
ArrayList<String> al5 = new ArrayList<String>();
ArrayList<String> al6 = new ArrayList<String>();
ArrayList<String> al7 = new ArrayList<String>();
ArrayList<String> al8 = new ArrayList<String>();
ArrayList<String> al9 = new ArrayList<String>();
static Integer Statisticsoccupy = 0;
Integer MyFriendSysNumInteger = 1999999;
int MyFriendSysNumint = 199999999;
MyLog waitNum = new MyLog(0);
String MyFriendIP = "";
static String MyFriendSysNum = "";
HashMap<Integer,JPanel> hmcenterjpanel = new HashMap<Integer,JPanel>();
HashMap<Integer,JLabel> hmsouthjpanel = new HashMap<Integer,JLabel>();
static JLabel jL = new JLabel();
JPanel d = null;
NextCustomerJButton c = null;
PreCustomerMyJButton p = null;
JPanel b = new JPanel();
JPanel jp = new JPanel();
String[] buffer = null;
public CardLayoutWindow() {
this.setBounds(new Rectangle(1038,590,_width,_height));
this.setTitle("学生等待室");
setLayout(new BorderLayout());
for(Integer i = 0;i<202;i++){
myMemWorkNum.put(i,false);
myDutyWorkNum.put(i,false);
}
//创建摆放“卡片切换”按钮的JPanel,并添加到Frame中
b.setLayout(new GridLayout(1,2));
p = new PreCustomerMyJButton("上一位",nowJPanelnum,mainnum,Chatword,MyFriendrole,this,jL,MyFriendSysNum);
c= new NextCustomerJButton("下一位",nowJPanelnum,mainnum,Chatword,MyFriendrole,this,jL,MyFriendSysNum);
b.add(p);
b.add(c);
add(BorderLayout.NORTH,b);
cards=new JPanel();//创建存放多个卡片
cards.setLayout(a);//设置为CardLayout
//创建cards的第一个JPanel和组件
d=new JPanel();
d.setLayout(new GridLayout(1,4));
d.add(new MakeMyServiceJButton("接"));
d.add(new MyJButtonWait("等"));
d.add(new MyJButtonRefuse("拒"));
d.add(new MyJButtonComplete("结"));
//创建cards的另一个JPanel和组件
for(Integer i =0;i<199;i++){
ArrayList<String> al = new ArrayList<String>();
hashTeacher.put(i, al);
}
// hmcenterjpanel.put(0, d);
// cards.add(hmcenterjpanel.get(0));
cards.add(BorderLayout.CENTER,d);
add(BorderLayout.CENTER,cards);//将cards放入Frame中
jL.setText("本"+nowJPanelnum.mylog+"席客户坐席为空"+":客户队列目前共"+mainnum.mylog+"人");
jp.add(jL);
add(BorderLayout.SOUTH,jp);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
pack();
setSize(_width, _height);
setVisible(true);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent p){
}
});
}
public void changeTitle(String Mytitle){
this.setTitle(Mytitle);
}
public void addJPanel(String MySocketData){
//创建cards的第一个JPanel和组件
if(Statisticsoccupy<9){
LocalMySocketData = MySocketData;
buffer = MySocketData.split("丠");
MyFriendSysNum = buffer[0];
MyFriendSysNumint = Integer.parseInt(MyFriendSysNum);
MyFriendSysNumInteger = new Integer(MyFriendSysNumint);
MyFriendrole = buffer[1];
MyFriendIP = buffer[2];
MyFriChatWord = buffer[3];
if(MyFriendrole.equals("Teacher")){
if(myMemWorkNum.get(MyFriendSysNumInteger)==false){
todaymyfriendDS.put(String.valueOf(nowJPanelnum), new MyFriendDS(MyFriendrole,nowJPanelnum,MyFriendSysNum,"待结"));
myMemWorkNum.put(MyFriendSysNumInteger, true);
nowJPanelnum.mylog++;
Statisticsoccupy++;
}else{
}
}else{
if(myDutyWorkNum.get(MyFriendSysNumInteger)==false){
todaymyfriendDS.put(String.valueOf(nowJPanelnum), new MyFriendDS(MyFriendrole,nowJPanelnum,MyFriendSysNum,"待结"));
myDutyWorkNum.put(MyFriendSysNumInteger, true);
nowJPanelnum.mylog++;
Statisticsoccupy++;
}else{
}
}
// cards.remove(hmcenterjpanel.get(0));
if(MyFriendrole.equals("Teacher")){
hashTeacher.get(MyFriendSysNumInteger).add(MySocketData);
String MyFriRole = "";
if(MyFriendrole.equals("Teacher")){
MyFriRole = "教师";
}else{
MyFriRole = "学生";
}
JPanel f=new JPanel();
JPanel f2 = new JPanel();
f.setLayout(new GridLayout(1,4));
f.add(new MakeMyServiceJButton("接",LocalMySocketData,MyFriRole,jL));
f.add(new MyJButtonWait("等",LocalMySocketData,MyFriRole,jL));
f.add(new MyJButtonRefuse("拒",LocalMySocketData,MyFriRole,jL));
f.add(new MyJButtonComplete("结",LocalMySocketData,MyFriRole,jL));
jL.setText("系统总数"+mainnum+",今天第"+nowJPanelnum.mylog+"单,用户编号:"+MyFriendSysNum+","+MyFriRole+"请求通信");
add(BorderLayout.SOUTH,f2);
f2.add(jL);
hmcenterjpanel.put(0,f);
cards.add(hmcenterjpanel.get(0));
JPCollectionTeacher.put(MyFriendSysNumInteger,f);
mainnum.mylog++;
//TODO:将本第142行的变量进行应用,将本变量传入“接”“等”“拒”“结”四个按钮中.进行“本系统中的:总是10位好友在排队”的功能的添加.
}else{
hashTeacher.get(MyFriendSysNumInteger).add(MySocketData);
String MyFriRole = "";
if(MyFriendrole.equals("Teacher")){
MyFriRole = "教师";
}else{
MyFriRole = "学生";
}
JPanel f=new JPanel();
JPanel f2 = new JPanel();
f.setLayout(new GridLayout(1,4));
f.add(new MakeMyServiceJButton("接",LocalMySocketData,MyFriRole,jL,mainnum,waitNum,nowJPanelnum));
f.add(new MyJButtonWait("等",LocalMySocketData,MyFriRole,jL,mainnum,waitNum));
f.add(new MyJButtonRefuse("拒",LocalMySocketData,MyFriRole,jL,mainnum,waitNum));
f.add(new MyJButtonComplete("结",LocalMySocketData,MyFriRole,jL,mainnum,waitNum));
jL.setText("系统总数"+mainnum+",今天第"+nowJPanelnum.mylog+"单,用户编号:"+MyFriendSysNum+","+MyFriRole+"请求通信");
add(BorderLayout.SOUTH,f2);
f2.add(jL);
hmcenterjpanel.put(0,f);
cards.add(hmcenterjpanel.get(0));
JPCollectionTeacher.put(MyFriendSysNumInteger,f);
mainnum.mylog++;
//TODO:将本第142行的变量进行应用,将本变量传入“接”“等”“拒”“结”四个按钮中.进行“本系统中的:总是10位好友在排队”的功能的添加.
}
}else{
SocketClient so = new SocketClient(Recv.S_PORT_SERVER,8811);
String str = "10丗0丗C丗Teacher丗"+Recv.MySystemserialnum;
so.writeStr(str, "CardLayoutWindow");
}
}
public static void main(String []args){
CardLayoutWindow h=new CardLayoutWindow();
h.addJPanel("0丠Teacher丠127.0.0.1丠CJCO!!");
h.addJPanel("1丠Teacher丠127.0.0.1丠CJCO!!");
h.addJPanel("2丠Teacher丠127.0.0.1丠CJCO!!");
h.addJPanel("3丠Teacher丠127.0.0.1丠CJCO!!");
h.addJPanel("4丠Teacher丠127.0.0.1丠CJCO!!");
h.addJPanel("5丠Teacher丠127.0.0.1丠CJCO!!");
h.addJPanel("6丠Teacher丠127.0.0.1丠CJCO!!");
h.addJPanel("7丠Teacher丠127.0.0.1丠CJCO!!");
}
@Override
public void windowActivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowClosed(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowClosing(WindowEvent arg0) {
// TODO Auto-generated method stub
this.dispose();
}
@Override
public void windowDeactivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowDeiconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowOpened(WindowEvent arg0) {
// TODO Auto-generated method stub
}
}
public class ATest extends javax.swing.JFrame {
private JPanel northPanel;
private JPanel centerPanel;
private JPanel southPanel;
public ATest() {
setLayout(new BorderLayout());
initNorthPanel();
add(northPanel, BorderLayout.NORTH);
initCenterPanel();
add(centerPanel, BorderLayout.CENTER);
initSouthPanel();
add(southPanel, BorderLayout.SOUTH);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
}
private void initNorthPanel(){
northPanel = new JPanel();
northPanel.setLayout(new GridLayout(1, 2));
JButton lastButton = new JButton("上一位");
JButton nextButton = new JButton("下一位");
northPanel.add(lastButton);
northPanel.add(nextButton);
}
private void initCenterPanel(){
centerPanel = new JPanel();
centerPanel.setLayout(new GridLayout(1, 4));
JButton acceptButton = new JButton("接");
JButton waitButton = new JButton("等");
JButton refuseButton = new JButton("拒");
JButton endButton = new JButton("结");
centerPanel.add(acceptButton);
centerPanel.add(waitButton);
centerPanel.add(refuseButton);
centerPanel.add(endButton);
}
private void initSouthPanel(){
southPanel = new JPanel();
southPanel.setLayout(new BorderLayout());
JLabel label = new JLabel("测试");
southPanel.add(label, BorderLayout.CENTER);
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ATest().setVisible(true);
}
});
}