📄 frame1.java
字号:
package tcpserver2;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.net.*;import java.io.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2006</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class Frame1 extends JFrame implements Runnable{{ JPanel contentPane; BorderLayout borderLayout1 = new BorderLayout(); TextArea textArea1 = new TextArea(); TextField textField1 = new TextField(); Button button1 = new Button(); Button button2 = new Button(); Label label1 = new Label(); //Construct the frame public Frame1() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(borderLayout1); this.setSize(new Dimension(400, 300)); this.setTitle("服务器端"); button1.setLabel("开始发送"); button1.addActionListener(new Frame1_button1_actionAdapter(this)); button2.setLabel("退出"); button2.addActionListener(new Frame1_button2_actionAdapter(this)); label1.setText("消息"); textArea1.setText(""); textField1.setText(""); contentPane.add(textField1, BorderLayout.CENTER); contentPane.add(button2, BorderLayout.WEST); contentPane.add(button1, BorderLayout.EAST); contentPane.add(textArea1, BorderLayout.SOUTH); contentPane.add(label1, BorderLayout.NORTH); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } void button1_actionPerformed(ActionEvent e) { } void button2_actionPerformed(ActionEvent e) { }}class Frame1_button1_actionAdapter implements java.awt.event.ActionListener { Frame1 adaptee; Frame1_button1_actionAdapter(Frame1 adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.button1_actionPerformed(e); }}class Frame1_button2_actionAdapter implements java.awt.event.ActionListener { Frame1 adaptee; Frame1_button2_actionAdapter(Frame1 adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.button2_actionPerformed(e); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -