//这是看了韩顺平老师的课跟着学的
//简易聊天界面
//主要有输入输出界面还有聊天人选择
import java.awt.*;
import javax.swing.*;
public class Text1 extends JFrame {
JTextArea jta;
JButton jb;
JTextField jtf;
JPanel jpl;
JComboBox jcb;
JScrollPane jsp;
public static void main(String[] args) {
// TODO Auto-generated method stub
Text1 t1 = new Text1();
}
public Text1(){
jta = new JTextArea();
jsp = new JScrollPane(jta);
jb = new JButton("发送");
String []chatter ={ "越南仔","元谋人"};
jcb = new JComboBox(chatter);
jtf = new JTextField(10);
jpl = new JPanel();
//添加组件
jpl.add(jcb);
jpl.add(jtf);
jpl.add(jb);
this.add(jsp);
this.add(jpl,BorderLayout.SOUTH);
//设置软件LOGO
this.setIconImage((new ImageIcon("图片//get.jpg")).getImage());
this.setTitle("腾讯QQ");
this.setSize(300,300);
this.setLocation(200,200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
}
————————————————————————————————————————————————————————————
//QQ登陆界面
//好吧,图片我弄小了(直接截的我的QQ登陆上的图片)。。。。。
//基本框架包含:号码输入,密码输入(隐藏输入),复选框,选项卡窗格可以根据QQ号码或手机号码和邮箱来切换不同的登陆界面,超链接的加入等等
import java.awt.*;
import javax.swing.*;
public class Text2 extends JFrame{
//北部
JLabel jl1;
//南部
JButton jb1,jb2,jb3;
JPanel jp1;
//中部
JTabbedPane jtp;//选项卡窗格
JPanel jp2,jp3,jp4;
JLabel jl2,jl3,jl4,jl5;
//号码输入
JTextField jtf;
//密码输入
JPasswordField jpf;
//清除号码按钮
JButton jb4;
//复选框 隐身登陆,记住密码
JCheckBox jcb1,jcb2;
public Text2(){
//北部
jl1 = new JLabel(new ImageIcon("图片//登陆.jpg"));
//中部
jl2 = new JLabel("QQ号码:",JLabel.CENTER);//QQ号码显示在JLabel的中间
jl3 = new JLabel("QQ密码:",JLabel.CENTER);
jl4 = new JLabel("忘记密码",JLabel.CENTER);
jl4.setFont(new Font("宋体",Font.PLAIN,16));//设置字体字号和样式
jl4.setForeground(Color.blue);
jl5 = new JLabel("<html><a href = 'www.qq.com'>申请密码保护</a></html>");
jl5.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
//选项卡窗格
jtp = new JTabbedPane();
jp2 = new JPanel();
jp3 = new JPanel();
jp3.setBackground(Color.BLACK);//设置背景色
jp4 = new JPanel();
jp4.setBackground(Color.WHITE);
jtf = new JTextField(10);
jpf = new JPasswordField(10);
jb4 = new JButton("清除号码");//在按钮中也可以添加图片new ImageIcon("xx//xx.jpg");
jcb1 = new JCheckBox("隐身登陆");
jcb2 = new JCheckBox("记住密码");
//南部
jp1 = new JPanel();
jb1 = new JButton("登陆");
jb2 = new JButton("取消");
jb3 = new JButton("注册");
//布局管理采用默认自动扩展填充
//添加组件
jp1.add(jb1);
jp1.add(jb2);
jp1.add(jb3);
//号码输入
jp2.add(jl2);
jp2.add(jtf);
//清空号码
jp2.add(jb4);
//密码输入
jp2.add(jl3);
jp2.add(jpf);
//忘记密码
jp2.add(jl4);
//复选框
jp2.add(jcb1);
jp2.add(jcb2);
//密保
jp2.add(jl5);
//将JPanel连入JTabbedPane
jtp.add("QQ号码",jp2);
jtp.add("手机号码",jp3);
jtp.add("电子邮箱",jp4);
this.add(jl1,BorderLayout.NORTH);
this.add(jp1,BorderLayout.SOUTH);
this.add(jtp,BorderLayout.CENTER);
//设置显示
this.setTitle("QQ2012");
this.setSize(400,300);
this.setLocation(200,200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Text2 t2 = new Text2();
}
}
