📄 userwin.java
字号:
package new3;
//import ne.Userwin_jButton1_actionAdapter;
//import ne.Userwin_jButton2_actionAdapter;
//import ne.Userwin;
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import java.awt.*;
import javax.swing.JTextArea;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import java.net.*;
import java.io.*;
import java.util.*;
/**
* <p>Title: </p>
*
* <p>Description: 天国工作室,聊天工具第二版</p>
*
* <p>Copyright: 版权所有Copyright (c) 2007</p>
*
* <p>Company: 天国工作室</p>
*
* @author not attributable
* @version 1.0
*/
public class Userwin extends JFrame {
ImageIcon icon_welcom=new ImageIcon("Image/as.gif");
Calendar objcalendar;
public Userwin() {
//objcalendar=Calendar.getInstance();
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
getContentPane().setLayout(null);
this.getContentPane().setBackground(Color.cyan);
this.setResizable(false);
this.setTitle("聊天窗口");
jButton1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jButton1.setActionCommand("btnok");
jButton2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jButton2.addActionListener(new Userwin_jButton2_actionAdapter(this));
jButton2.setBounds(new Rectangle(24, 392, 149, 30));
jButton2.setText("关闭");
jButton1.setBounds(new Rectangle(231, 389, 157, 30));
jButton1.setText("发送");
jButton1.addActionListener(new Userwin_jButton1_actionAdapter(this));
jScrollPane1.setBounds(new Rectangle(3, 296, 409, 89));
jScrollPane2.setBounds(new Rectangle(2, 3, 405, 239));
txtjieshou.setText("");
txtfasong.setText("");
jLabel1.setIcon(icon_welcom);
jLabel1.setBounds(new Rectangle(5, 249, 38, 24));
jLabel2.setIcon(icon_welcom);
jLabel2.setBounds(new Rectangle(132, 248, 35, 26));
jLabel3.setIcon(icon_welcom);
jLabel3.setBounds(new Rectangle(219, 255, 35, 26));
jLabel4.setIcon(icon_welcom);
jLabel4.setBounds(new Rectangle(270, 263, 35, 26));
jLabel5.setIcon(icon_welcom);
jLabel5.setBounds(new Rectangle(312, 259, 35, 26));
jLabel6.setIcon(icon_welcom);
jLabel6.setBounds(new Rectangle(91, 260, 35, 26));
jLabel7.setIcon(icon_welcom);
jLabel7.setBounds(new Rectangle(367, 257, 35, 26));
jLabel8.setIcon(icon_welcom);
jLabel8.setBounds(new Rectangle(170, 260, 35, 26));
jLabel9.setIcon(icon_welcom);
jLabel9.setBounds(new Rectangle(44, 267, 35, 26));
this.getContentPane().add(jButton2);
this.getContentPane().add(jButton1);
this.getContentPane().add(jScrollPane1);
jScrollPane1.getViewport().add(txtfasong);
this.getContentPane().add(jScrollPane2);
this.getContentPane().add(jLabel1);
this.getContentPane().add(jLabel9);
this.getContentPane().add(jLabel6);
this.getContentPane().add(jLabel2);
this.getContentPane().add(jLabel8);
this.getContentPane().add(jLabel3);
this.getContentPane().add(jLabel4);
this.getContentPane().add(jLabel5);
this.getContentPane().add(jLabel7);
jScrollPane2.getViewport().add(txtjieshou);
}
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JScrollPane jScrollPane1 = new JScrollPane();
JScrollPane jScrollPane2 = new JScrollPane();
JTextArea txtjieshou = new JTextArea();
JTextArea txtfasong = new JTextArea();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
JLabel jLabel5 = new JLabel();
JLabel jLabel6 = new JLabel();
JLabel jLabel7 = new JLabel();
JLabel jLabel8 = new JLabel();
JLabel jLabel9 = new JLabel();
public void jButton2_actionPerformed(ActionEvent e) {
System.exit(0);
}
public void jButton1_actionPerformed(ActionEvent e) {
String fasong=txtfasong.getText();
try{
Socket so = new Socket("192.168.1.156", 4003);
PrintStream p=new PrintStream(so.getOutputStream());
p.println(fasong);
so.close();
}catch(Exception ce){
System.out.println("异常"+ce);
}
txtfasong.setText("");
}
/**void settxt(String set,String name){
objcalendar=Calendar.getInstance();
int year = objcalendar.get(Calendar.YEAR),
month = objcalendar.get(Calendar.MONTH);
int date = objcalendar.get(Calendar.DATE),
hour = objcalendar.get(Calendar.HOUR);
int minute = objcalendar.get(Calendar.MINUTE),
second = objcalendar.get(Calendar.SECOND);
int apm = objcalendar.get(Calendar.AM_PM);
if(apm==1)
hour=hour+12;
String timestr=year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second+"\t";
String str=txtjieshou.getText();
txtjieshou.setText(str+"\n"+timestr+" "+name+"\n"+set);
}*/
String userid(String name){
return name;
}
public void set(String str){
objcalendar=Calendar.getInstance();
int year = objcalendar.get(Calendar.YEAR),
month = objcalendar.get(Calendar.MONTH);
int date = objcalendar.get(Calendar.DATE),
hour = objcalendar.get(Calendar.HOUR);
int minute = objcalendar.get(Calendar.MINUTE),
second = objcalendar.get(Calendar.SECOND);
int apm = objcalendar.get(Calendar.AM_PM);
if(apm==1)
hour=hour+12;
String timestr=year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second+"\t";
String str1=txtjieshou.getText();
txtjieshou.setText(str1+"\n"+timestr+" "/*+name*/+"\t"+str);
}
}
class Userwin_jButton1_actionAdapter implements ActionListener {
private Userwin adaptee;
Userwin_jButton1_actionAdapter(Userwin adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
class Userwin_jButton2_actionAdapter implements ActionListener {
private Userwin adaptee;
Userwin_jButton2_actionAdapter(Userwin adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -