chessinterface.java~23~

来自「是JB的2D网络游戏」· JAVA~23~ 代码 · 共 65 行

JAVA~23~
65
字号
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;

//用户列表,含有一个List,里面含有用户的信息
class userPad  extends Panel{
  List userList = new List(10);
  userPad(){
    setLayout(new BorderLayout());
    for(int i = 0; i < 50; i++){
      userList.add(i + "." + "没有用户");
    }
    add(userList, BorderLayout.CENTER);
  }
}
//聊天信息的Panel,里面含有一个TextArea;
class chatPad
    extends Panel{
  TextArea chatLineArea = new TextArea("", 18, 30,
                                       TextArea.SCROLLBARS_VERTICAL_ONLY);
  chatPad(){
    setLayout(new BorderLayout());
    add(chatLineArea, BorderLayout.CENTER);
  }
}
//控制面板,输入ip地址的文本框:inputIP,含有connectButton,createGameButton
//,joinGameButton,cancelGameButton,exitGameButton按钮
class controlPad
    extends Panel{
  Label IPlabel = new Label("IP", Label.LEFT);
  TextField inputIP = new TextField("localhost", 10);
  Button connectButton = new Button("连接主机");
  Button creatGameButton = new Button("建立游戏");
  Button joinGameButton = new Button("加入游戏");
  Button cancelGameButton = new Button("放弃游戏");
  Button exitGameButton = new Button("关闭程序");
  controlPad(){
    setLayout(new FlowLayout(FlowLayout.LEFT));
    setBackground(Color.pink);
    add(IPlabel);
    add(inputIP);
    add(connectButton);
    add(creatGameButton);
    add(joinGameButton);
    add(cancelGameButton);
    add(exitGameButton);
  }
}
//输入Panel,含有一个下拉列表和输入聊天信息的文本框
class inputPad
    extends Panel {
  TextField inputWords = new TextField("", 40);
  Choice userChoice = new Choice();
  inputPad(){
    setLayout(new FlowLayout(FlowLayout.LEFT));
    for(int i = 0; i < 50; i++){
      userChoice.addItem(i + "." + "没有用户");
    }
    userChoice.setSize(60, 24);
    add(userChoice);
    add(inputWords);
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?