⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testframe.java~5~

📁 俄罗斯方块源码 实现网络游戏分为client和server两部分
💻 JAVA~5~
字号:
package client;import java.awt.*;import javax.swing.*;import java.awt.event.*;/** * Title: * Description: * Copyright:    Copyright (c) 2001 * Company: * @author * @version 1.0 */public class TestFrame extends Panel{    JTextField jTextField1 = new JTextField();    JButton jButton1 = new JButton();    JLabel jLabel1 = new JLabel();    TextArea textArea1 = new TextArea();    MyClient m_socket=null;    public TestFrame()    {        try {            jbInit();            m_socket=new MyClient("sxf",this);        }        catch(Exception e) {            e.printStackTrace();        }    }    public static void main(String[] args)    {        TestFrame testFrame1 = new TestFrame();        Frame f=new Frame("聊天");        f.setSize(470,320);        f.add(testFrame1);        f.show();    }    private void jbInit() throws Exception {        jTextField1.setBounds(new Rectangle(157, 254, 197, 22));        this.setLayout(null);        jButton1.setText("发送");        jButton1.setBounds(new Rectangle(363, 250, 79, 29));        jButton1.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(ActionEvent e) {                jButton1_actionPerformed(e);            }        });        jLabel1.setText("请输入现在要发送的消息:");        jLabel1.setBounds(new Rectangle(11, 257, 145, 18));        textArea1.setBounds(new Rectangle(18, 16, 426, 219));        this.add(jLabel1, null);        this.add(jTextField1, null);        this.add(jButton1, null);        this.add(textArea1, null);    }    void jButton1_actionPerformed(ActionEvent e)    {        String str=jTextField1.getText().trim();        sendText(str);        textArea1.setForeground(Color.red);        textArea1.append("I say:"+str+"\n");    }    private void sendText(String str)    {        m_socket.writeStr(str);    }    public void readStr(String str)    {        textArea1.setForeground(Color.green);        textArea1.append("You say:"+str+"\n");    }    public void showMessage(String str)    {        textArea1.setForeground(Color.black);        textArea1.append("You say:"+str+"\n");    }}

⌨️ 快捷键说明

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