这里代码主要实现的是一套聊天系统的ui界面,下载源代码链接https://download.csdn.net/download/qq_44716544/12352588
运行效果如下:
代码如下:
//启动页的代码
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Startpage extends JFrame implements ActionListener{
private JLabel imagelabel=new JLabel();
public static void main(String[] args) {
// TODO Auto-generated method stub
new Startpage();
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
public Startpage(){
this.setTitle("联系人");
this.setLocation(500, 150);
this.setSize(500, 800);
this.setLayout(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
ImageIcon image=new ImageIcon("image/启动页.png");
imagelabel = new JLabel(image);
imagelabel.setBounds(0,0,485,800);
this.add(imagelabel);
this.setVisible(true);
B b=new B();
try{
Thread.sleep(1800);
b.start();
}catch(InterruptedException e){
e.printStackTrace();
}
}
class B extends Thread{
public void run(){
Startpage.this.dispose();
new UserLogin();
}
}}
//登陆页的代码
import info.User;
import java.awt.Color;
import java.awt.Font;
import java.awt.Image;
import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.awt.image.*;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import java.awt.event.ActionEvent;
import javax.swing.ImageIcon;
public class UserLogin extends JFrame implements ActionListener{
private JTextField fieldAccount = new JTextField();
private JPasswordField fieldPassword = new JPasswordField();
private JButton buttonLogin = new JButton("登 陆");
private JButton buttonRegister = new JButton("立即注册>");
private JLabel imagelabel=new JLabel();
public static void main(String[] args) {
new UserLogin();
}
public UserLogin() {
this.setTitle("用户登陆");
this.setLocation(500, 150);
this.setSize(500, 800);
this.setLayout(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setResizable(false);
ImageIcon image=new ImageIcon("image/登录页.jpg");
imagelabel = new JLabel(image);
imagelabel.setBounds(0,0,500,800);
JLabel labelAccount = new JLabel("账 号");
labelAccount.setAlignmentY(CENTER_ALIGNMENT);
labelAccount.setBounds(90, 325, 50, 40);
fieldAccount.setBounds(175, 325, 175, 40);
//fieldAccount.setOpaque(false);
//fieldAccount.setBorder(null);
labelAccount.setForeground(Color.blue);
labelAccount.setBackground(new Color(30, 144, 255));
this.getContentPane().add(labelAccount);
this.getContentPane().add(fieldAccount);
JLabel labelPwd = new JLabel("密 码");
labelPwd.setAlignmentY(CENTER_ALIGNMENT);
labelPwd.setBounds(90, 400, 50, 40);
fieldPassword.setBounds(175, 400, 175, 40);
//fieldPassword.setOpaque(false);
//fieldPassword.setBorder(null);
labelPwd.setForeground(Color.blue);
labelPwd.setBackground(new Color(30, 144, 255));
this.getContentPane().add(labelPwd);
this.getContentPane().add(fieldPassword, BorderLayout.CENTER);
buttonRegister.setBounds(175, 650, 150, 40);
buttonRegister.setForeground(Color.blue);
buttonRegister.setBackground(new Color(30, 144, 255));
buttonRegister.setOpaque(false);
buttonRegister.setBorder(null);
this.getContentPane().add(buttonRegister);
buttonRegister.addActionListener(this);
buttonLogin.setBounds(175, 475, 150, 40);
buttonLogin.setForeground(Color.white);
buttonLogin.setBackground(new Color(30, 144, 255));
// buttonLogin.setOpaque(false);
//buttonLogin.setBorder(null);
this.getContentPane().add(buttonLogin);
buttonLogin.addActionListener(this);
this.add(imagelabel);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == buttonLogin){
String account = fieldAccount.getText();
String password = new String(fieldPassword.getPassword());
User user = verifyAccount(account, password);
if( user != null){
new Message();
this.dispose();
}
else{
JOptionPane.showMessageDialog(null, "身份错误");}
}
else{
JOptionPane.showMessageDialog(this, "账号或密码错误");
fieldPassword.setText(null);
}
if (e.getSource() == buttonRegister){
new UserRegister();
this.dispose();
}
}
private User verifyAccount(String account, String password) {
// 这里固定用户名和密码为 XXX/XXX
if(account.equals("XXX") && password.equals("XXX")){
User user = new User();
user.setId(1);
return user;
}
return null;
}
}
//注册页的代码
import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class UserRegister extends JFrame implements ActionListener{
private JTextField fieldAccount = new JTextField();
private JPasswordField fieldPassword = new JPasswordField();
// private JVerificationcodeField fieldVerificationcode = new JVerificationcodeField();
private JButton buttonLogin = new JButton("立即登入>");
private JButton buttonRegister = new JButton("注 册");
private JButton buttonVerificationcode = new JButton("获取验证码");
private JTextField Verificationcode =new JTextField();
private JLabel imagelabel=new JLabel();
public static void main(String[] args) {
new UserRegister();
}
public UserRegister() {
this.setTitle("联系人");
this.setLocation(500, 150);
this.setSize(500, 800);
this.setLayout(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setResizable(false);
ImageIcon image=new ImageIcon("image/登录页.jpg");
imagelabel = new JLabel(image);
imagelabel.setBounds(0,0,500,800);
JLabel labelAccount = new JLabel("请输入账号");
labelAccount.setAlignmentY(CENTER_ALIGNMENT);
labelAccount.setBounds(75, 300, 100, 40);
fieldAccount.setBounds(175, 300, 150, 40);
this.getContentPane().add(labelAccount);
this.getContentPane().add(fieldAccount);
JLabel labelVerificationcode = new JLabel("验证码");
labelVerificationcode.setAlignmentY(CENTER_ALIGNMENT);
labelVerificationcode.setBounds(85, 350, 100, 40);
Verificationcode.setBounds(175, 350, 150, 40);
this.getContentPane().add(labelVerificationcode);
this.getContentPane().add(Verificationcode);
//this.getContentPane().add(fieldVerificationcode, BorderLayout.CENTER);
JLabel labelPwd = new JLabel("密码");
labelPwd.setAlignmentY(CENTER_ALIGNMENT);
labelPwd.setBounds(100, 400, 100, 40);
fieldPassword.setBounds(175, 400, 150, 40);
this.getContentPane().add(labelPwd);
this.getContentPane().add(fieldPassword, BorderLayout.CENTER);
buttonLogin.setBounds(175, 700, 150, 40);
buttonLogin.setForeground(Color.blue);
buttonLogin.setBackground(new Color(30, 144, 255));
buttonLogin.setOpaque(false);
buttonLogin.setBorder(null);
this.getContentPane().add(buttonLogin);
buttonLogin.addActionListener(this);
buttonRegister.setBounds(175, 500, 150, 40);
buttonRegister.setForeground(Color.white);
buttonRegister.setBackground(new Color(30, 144, 255));
this.getContentPane().add(buttonRegister);
buttonRegister.addActionListener(this);
buttonVerificationcode.setBounds(325, 350, 100, 40);
buttonVerificationcode.setForeground(Color.blue);
buttonVerificationcode.setBackground(new Color(30, 144, 255));
buttonVerificationcode.setOpaque(false);
buttonVerificationcode.setBorder(null);
this.getContentPane().add(buttonVerificationcode);
this.add(imagelabel);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == buttonLogin){
new UserLogin();
this.dispose();
}
else{}
}
}
//消息页的代码
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
public class Message extends JFrame implements ActionListener{
/**
*
*/
private static final long serialVersionUID = 7136204159396117422L;
//private JButton buttonSearch = new JButton("搜索");
private JButton buttonNews = new JButton("消息");
private JButton buttonContacts = new JButton("联系人");
private JButton buttonMe = new JButton("我的");
private JLabel liaotian=new JLabel("聊天");
private JTextField search = new JTextField();
private JLabel labelnews=new JLabel();
private JLabel labelcontacts=new JLabel();
private JLabel labelme=new JLabel();
private JLabel imagelabel=new JLabel();
private JLabel biaoqianlan=new JLabel();//标签栏背景
public static void main(String[] args) {
new Message();}
public Message() {
this.setTitle("消息");
this.setLocation(500, 150);
this.setSize(500, 800);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setLayout(null);
ImageIcon image=new ImageIcon("image/背景图片.png");
imagelabel = new JLabel(image);
imagelabel.setBounds(0,0,485,800);
ImageIcon image8=new ImageIcon("image/标签栏背景.png");
biaoqianlan = new JLabel(image8);
biaoqianlan.setBounds(0, 655, 500, 100);
ImageIcon image1=new ImageIcon("image/消息图标1.png");
labelnews = new JLabel(image1);
labelnews.setBounds(27,620,70,135);
this.add(labelnews);
ImageIcon image2=new ImageIcon("image/联系人图标1.png");
labelcontacts = new JLabel(image2);
labelcontacts.setBounds(202,620,70,135);
this.add(labelcontacts);
ImageIcon image3=new ImageIcon("image/我的图标1.png");
labelme = new JLabel(image3);
labelme.setBounds(375,620,70,135);
this.add(labelme);
liaotian.setBounds(212, 2, 50, 40);
liaotian.setFont(new Font("微软雅黑",Font.PLAIN,18));
this.add(liaotian);
search.setBounds(25, 55, 450, 45);
search.setOpaque(false);
search.setBorder(null);
this.getContentPane().add(search);
search.setText("搜索");
buttonNews.setBounds(25, 675, 75, 90);
buttonNews.setForeground(Color.blue);
buttonNews.setBackground(new Color(30, 144, 255));
buttonNews.setOpaque(false);
buttonNews.setBorder(null);
this.getContentPane().add(buttonNews);
buttonNews.addActionListener(this);
buttonContacts.setBounds(200, 675, 75, 90);
buttonContacts.setForeground(Color.gray);
buttonContacts.setBackground(new Color(30, 144, 255));
buttonContacts.setOpaque(false);
buttonContacts.setBorder(null);
this.getContentPane().add(buttonContacts);
buttonContacts.addActionListener(this);
buttonMe.setBounds(375, 675, 75, 90);
buttonMe.setForeground(Color.gray);
buttonMe.setBackground(new Color(30, 144, 255));
buttonMe.setOpaque(false);
buttonMe.setBorder(null);
this.getContentPane().add(buttonMe);
buttonMe.addActionListener(this);
this.add(biaoqianlan);
this.add(imagelabel);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == buttonContacts){
new ChatDetails();
this.dispose();
}
else if(e.getSource() == buttonMe){
new Me();
this.dispose();
}
}
}
//我的页代码
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
public class Me extends JFrame implements ActionListener{
private JButton buttonHeadportrait = new JButton();//头像
private JButton buttondynamic = new JButton();//动态
private JButton buttondata= new JButton();//资料
private JButton buttonSetup= new JButton();//设置
private JLabel labeldynamic=new JLabel("动态");
private JLabel labelsetup=new JLabel("设置");
private JLabel labeldata=new JLabel("资料");
private JLabel labeldynamic1=new JLabel(">");
private JLabel labelsetup1=new JLabel(">");
private JLabel labeldata1=new JLabel(">");
private JLabel dongtaitubiao=new JLabel();//动态图标
private JLabel ziliaotubiao=new JLabel();//资料图标
private JLabel shezhitubiao=new JLabel();//设置图标
private JLabel xiantubiao=new JLabel();//线图标
private JLabel xiantubiao1=new JLabel();//线图标1
private JLabel xiantubiao2=new JLabel();//线图标2
private JLabel biaoqianlan=new JLabel();//标签栏背景
private JButton buttonNews = new JButton("消息");
private JButton buttonContacts = new JButton("联系人");
private JButton buttonMe = new JButton("我 的");
private JLabel labelnews=new JLabel();
private JLabel labelcontacts=new JLabel();
private JLabel labelme=new JLabel();
private JLabel labelmetouxiang=new JLabel();
private JLabel imagelabel=new JLabel();
public static void main(String[] args) {
new Me();
}
public Me() {
this.setTitle("聊天详情");
this.setLocation(500, 150);
this.setSize(500, 800);
this.setLayout(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
ImageIcon image=new ImageIcon("image/我的背景图.png");
imagelabel = new JLabel(image);
imagelabel.setBounds(0,0,485,800);
ImageIcon image1=new ImageIcon("image/白色消息1.png");
labelnews = new JLabel(image1);
labelnews.setBounds(27,620,70,135);
this.add(labelnews);
ImageIcon image2=new ImageIcon("image/联系人图标1.png");
labelcontacts = new JLabel(image2);
labelcontacts.setBounds(202,620,70,135);
this.add(labelcontacts);
ImageIcon image3=new ImageIcon("image/蓝色我的图标1.png");
labelme = new JLabel(image3);
labelme.setBounds(377,620,70,135);
this.add(labelme);
ImageIcon image4=new ImageIcon("image/我的头像图片.png");
labelmetouxiang = new JLabel(image4);
labelmetouxiang.setBounds(340, 140, 100, 100);
this.add(labelmetouxiang);
ImageIcon image5=new ImageIcon("image/动态图标.png");
dongtaitubiao = new JLabel(image5);
dongtaitubiao.setBounds(30, 260, 50,40);
this.add(dongtaitubiao);
ImageIcon image51=new ImageIcon("image/线.png");
xiantubiao = new JLabel(image51);
xiantubiao.setBounds(30, 290, 400, 40);
this.add(xiantubiao);
ImageIcon image6=new ImageIcon("image/资料图标.png");
ziliaotubiao = new JLabel(image6);
ziliaotubiao.setBounds(30, 320, 50, 40);
this.add(ziliaotubiao);
ImageIcon image61=new ImageIcon("image/线.png");
xiantubiao1 = new JLabel(image61);
xiantubiao1.setBounds(30, 350, 400, 40);
this.add(xiantubiao1);
ImageIcon image7=new ImageIcon("image/设置图标.png");
shezhitubiao = new JLabel(image7);
shezhitubiao.setBounds(30, 380, 50, 40);
this.add(shezhitubiao);
ImageIcon image71=new ImageIcon("image/线.png");
xiantubiao2 = new JLabel(image71);
xiantubiao2.setBounds(30, 410, 400, 40);
this.add(xiantubiao2);
ImageIcon image8=new ImageIcon("image/标签栏背景.png");
biaoqianlan = new JLabel(image8);
biaoqianlan.setBounds(0, 655, 500, 100);
JLabel labelAccount = new JLabel("我的");
labelAccount.setBounds(212, 2, 50, 40);
labelAccount.setFont(new Font("微软雅黑",Font.PLAIN,18));
// private JLabel labeldynamic=new JLabel("动态");
// private JLabel labelsetup=new JLabel("设置");
// private JLabel labeldata=new JLabel("资料");
buttonHeadportrait.setBounds(340, 140, 100, 100);
buttonHeadportrait.setBackground(new Color(30, 144, 255));
buttonHeadportrait.setOpaque(false);
buttonHeadportrait.setBorder(null);
this.getContentPane().add(buttonHeadportrait);
buttonHeadportrait.addActionListener(this);
buttondynamic.setBounds(40, 260, 400, 40);
labeldynamic.setBounds(80, 260, 50, 40);
labeldynamic1.setBounds(425, 260, 50, 40);
buttondynamic.setBackground(new Color(255, 255, 255));
buttondynamic.setOpaque(false);
buttondynamic.setBorder(null);
this.getContentPane().add(buttondynamic);
this.add(labeldynamic);
this.add(labeldynamic1);
buttondynamic.addActionListener(this);
buttondata.setBounds(40, 320, 400, 40);
labeldata.setBounds(80, 320, 50, 40);
labeldata1.setBounds(425, 320, 50, 40);
buttondata.setBackground(new Color(30, 144, 255));
buttondata.setOpaque(false);
buttondata.setBorder(null);
this.add(labeldata);
this.add(labeldata1);
this.getContentPane().add(buttondata);
buttondata.addActionListener(this);
buttonSetup.setBounds(40, 380, 400, 40);
labelsetup.setBounds(80, 380, 50, 40);
labelsetup1.setBounds(425, 380, 50, 40);
buttonSetup.setBackground(new Color(30, 144, 255));
buttonSetup.setOpaque(false);
buttonSetup.setBorder(null);
this.add(labelsetup);
this.add(labelsetup1);
this.getContentPane().add(buttonSetup);
buttonSetup.addActionListener(this);
buttonNews.setBounds(25, 675, 75, 90);
buttonNews.setForeground(Color.gray);
buttonNews.setBackground(new Color(30, 144, 255));
buttonNews.setOpaque(false);
buttonNews.setBorder(null);
this.getContentPane().add(buttonNews);
buttonNews.addActionListener(this);
buttonContacts.setBounds(200, 675, 75, 90);
buttonContacts.setForeground(Color.gray);
buttonContacts.setBackground(new Color(30, 144, 255));
buttonContacts.setOpaque(false);
buttonContacts.setBorder(null);
this.getContentPane().add(buttonContacts);
buttonContacts.addActionListener(this);
buttonMe.setBounds(375, 675, 75, 90);
buttonMe.setForeground(Color.blue);
buttonMe.setBackground(new Color(30, 144, 255));
buttonMe.setOpaque(false);
buttonMe.setBorder(null);
this.getContentPane().add(buttonMe);
buttonMe.addActionListener(this);
this.add(biaoqianlan);
this.add(labelAccount);
this.add(imagelabel);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == buttonContacts){
new ChatDetails();
this.dispose();
}
else if(e.getSource() == buttonNews){
Message user = new Message();
this.dispose();
}
else if (e.getSource() == buttonHeadportrait){
JOptionPane.showMessageDialog(this, "不好意思,头像功能未开启");
//new ChatDetails();
//this.dispose();
}
else if(e.getSource().equals(buttonSetup)){
new SetUp();
this.dispose();
}
}
}
//联系人界面的代码
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import java.awt.event.ActionEvent;
public class ChatDetails extends JFrame implements ActionListener{
private JButton buttonAddfriends = new JButton();
private JLabel labeladdfriends=new JLabel("添加好友");
private JLabel labeladdfriends1=new JLabel(">");
private JLabel labeladdfriends2=new JLabel();
private JButton buttonApplicationandnotice = new JButton();
private JLabel labelapplicationandnotice=new JLabel("申请与通知");
private JLabel labelapplicationandnotice1=new JLabel(">");
private JLabel labelapplicationandnotice2=new JLabel();
private JButton buttonGroupchat = new JButton();
private JLabel labelgroupchat=new JLabel("群聊");
private JLabel labelgroupchat1=new JLabel(">");
private JLabel labelgroupchat2=new JLabel();
private JButton buttonNews = new JButton("消息");
private JButton buttonContacts = new JButton("联系人");
private JButton buttonMe = new JButton("我 的");
private JLabel labelnews=new JLabel();
private JLabel labelcontacts=new JLabel();
private JLabel labelme=new JLabel();
private JLabel imagelabel=new JLabel();
private JTextField search = new JTextField();
private JLabel xiantubiao=new JLabel();//线图标
private JLabel xiantubiao1=new JLabel();//线图标1
private JLabel xiantubiao2=new JLabel();//线图标2
private JLabel biaoqianlan=new JLabel();//标签栏背景
public static void main(String[] args) {
new ChatDetails();
}
public ChatDetails() {
this.setTitle("联系人");
this.setLocation(500, 150);
this.setSize(500, 800);
this.setLayout(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
ImageIcon image=new ImageIcon("image/背景图片.png");
imagelabel = new JLabel(image);
imagelabel.setBounds(0,0,485,800);
ImageIcon image1=new ImageIcon("image/白色消息1.png");
labelnews = new JLabel(image1);
labelnews.setBounds(27,622,70,135);
this.add(labelnews);
ImageIcon image2=new ImageIcon("image/蓝色联系人1.png");
labelcontacts = new JLabel(image2);
labelcontacts.setBounds(202,620,70,135);
this.add(labelcontacts);
ImageIcon image3=new ImageIcon("image/我的图标1.png");
labelme = new JLabel(image3);
labelme.setBounds(377,620,70,135);
this.add(labelme);
ImageIcon image4=new ImageIcon("image/添加好友图标.png");
labeladdfriends2 = new JLabel(image4);
labeladdfriends2.setBounds(15,120,55,35);
this.add(labeladdfriends2);
ImageIcon image5=new ImageIcon("image/申请与通知图标.png");
labelapplicationandnotice2 = new JLabel(image5);
labelapplicationandnotice2.setBounds(15,173,55,35);
this.add(labelapplicationandnotice2);
ImageIcon image6=new ImageIcon("image/群聊图标.png");
labelgroupchat2 = new JLabel(image6);
labelgroupchat2.setBounds(17,227,55,35);
this.add(labelgroupchat2);
ImageIcon image8=new ImageIcon("image/标签栏背景.png");
biaoqianlan = new JLabel(image8);
biaoqianlan.setBounds(0, 655, 500, 100);
search.setBounds(25, 55, 450, 45);
search.setOpaque(false);
search.setBorder(null);
this.getContentPane().add(search);
search.setText("搜索");
JLabel labelAccount = new JLabel("联系人");
labelAccount.setBounds(205, 2, 70, 40);
labelAccount.setFont(new Font("微软雅黑",Font.PLAIN,18));
this.getContentPane().add(labelAccount);
ImageIcon image51=new ImageIcon("image/线.png");
xiantubiao = new JLabel(image51);
xiantubiao.setBounds(50, 143, 400, 40);
this.add(xiantubiao);
buttonAddfriends.setBounds(20, 120, 450, 35);
labeladdfriends.setBounds(70,120,75,35);
labeladdfriends1.setBounds(450,120,75,35);
//buttonAddfriends.setForeground(Color.blue);
buttonAddfriends.setBackground(new Color(30, 144, 255));
buttonAddfriends.setOpaque(false);
buttonAddfriends.setBorder(null);
this.add(labeladdfriends);
this.add(labeladdfriends1);
this.getContentPane().add(buttonAddfriends);
buttonAddfriends.addActionListener(this);
ImageIcon image61=new ImageIcon("image/线.png");
xiantubiao1 = new JLabel(image61);
xiantubiao1.setBounds(50, 198, 400, 40);
this.add(xiantubiao1);
buttonApplicationandnotice.setBounds(20, 173, 450, 35);
labelapplicationandnotice.setBounds(70,173,75,35);
labelapplicationandnotice1.setBounds(450,173,75,35);
buttonApplicationandnotice.setBackground(new Color(30, 144, 255));
buttonApplicationandnotice.setOpaque(false);
buttonApplicationandnotice.setBorder(null);
this.add(labelapplicationandnotice);
this.add(labelapplicationandnotice1);
this.getContentPane().add(buttonApplicationandnotice);
buttonApplicationandnotice.addActionListener(this);
ImageIcon image71=new ImageIcon("image/线.png");
xiantubiao2 = new JLabel(image71);
xiantubiao2.setBounds(50, 252, 400, 40);
this.add(xiantubiao2);
buttonGroupchat.setBounds(20, 227, 450, 35);
labelgroupchat.setBounds(70,227,75,35);
labelgroupchat1.setBounds(450,227,75,35);
buttonGroupchat.setBackground(new Color(30, 144, 255));
buttonGroupchat.setOpaque(false);
buttonGroupchat.setBorder(null);
this.add(labelgroupchat);
this.add(labelgroupchat1);
this.getContentPane().add(buttonGroupchat);
buttonGroupchat.addActionListener(this);
buttonNews.setBounds(25, 675, 75, 90);
buttonNews.setForeground(Color.gray);
buttonNews.setBackground(new Color(30, 144, 255));
buttonNews.setOpaque(false);
buttonNews.setBorder(null);
this.getContentPane().add(buttonNews);
buttonNews.addActionListener(this);
buttonContacts.setBounds(200, 675, 75, 90);
buttonContacts.setForeground(Color.blue);
buttonContacts.setBackground(new Color(30, 144, 255));
buttonContacts.setOpaque(false);
buttonContacts.setBorder(null);
this.getContentPane().add(buttonContacts);
buttonContacts.addActionListener(this);
buttonMe.setBounds(375, 675, 75, 90);
buttonMe.setForeground(Color.gray);
buttonMe.setBackground(new Color(30, 144, 255));
buttonMe.setOpaque(false);
buttonMe.setBorder(null);
this.getContentPane().add(buttonMe);
buttonMe.addActionListener(this);
this.add(biaoqianlan);
this.add(imagelabel);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == buttonMe){
new Me();
this.dispose();
}
else if(e.getSource() == buttonNews){
Message user = new Message();
this.dispose();
}
}}
//设置界面的代码
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
public class SetUp extends JFrame implements ActionListener{
/**
* @param args
*/
private JButton backout= new JButton("<");
private JButton quit = new JButton("退出登陆");
private JLabel labelquit=new JLabel("退出登陆");
private JButton aboutus = new JButton();//关于我们
private JLabel labelaboutus=new JLabel("关于我们");
private JLabel labelaboutus1=new JLabel(">");
private JButton developmenttime= new JButton();//开发时间
private JLabel labeldevelopmenttime=new JLabel("开发时间");
private JLabel labeldevelopmenttime1=new JLabel(">");
private JLabel labelsetup=new JLabel("设置");
private JLabel labelimage=new JLabel();
private JLabel xiantubiao=new JLabel();//线图标
private JLabel xiantubiao1=new JLabel();//线图标
public static void main(String[] args) {
// TODO Auto-generated method stub
new SetUp();
}
public SetUp(){
this.setTitle("设置");
this.setLocation(500, 150);
this.setSize(500, 800);
this.setLayout(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
ImageIcon image=new ImageIcon("image/设置背景图片.png");
labelimage = new JLabel(image);
labelimage.setBounds(0,0,485,800);
labelsetup.setBounds(218, 1, 70, 40);
labelsetup.setFont(new Font("微软雅黑",Font.PLAIN,18));
this.add(labelsetup);
backout.setBounds(2, 0, 50, 40);
backout.setForeground(Color.white);
backout.setBackground(new Color(30, 144, 255));
backout.setOpaque(false);
backout.setBorder(null);
this.getContentPane().add(backout);
backout.addActionListener(this);
ImageIcon image1=new ImageIcon("image/线.png");
xiantubiao = new JLabel(image1);
xiantubiao.setBounds(5, 90, 430, 20);
this.add(xiantubiao);
labelaboutus.setBounds(15, 50, 100, 40);
labelaboutus1.setBounds(458, 50, 100, 40);
aboutus.setBounds(2, 50, 478, 40);
aboutus.setForeground(Color.gray);
aboutus.setBackground(new Color(30, 144, 255));
aboutus.setOpaque(false);
aboutus.setBorder(null);
this.add(labelaboutus);
this.add(labelaboutus1);
this.getContentPane().add(aboutus);
aboutus.addActionListener(this);
ImageIcon image2=new ImageIcon("image/线.png");
xiantubiao1 = new JLabel(image2);
xiantubiao1.setBounds(5, 150, 430, 20);
this.add(xiantubiao1);
labeldevelopmenttime.setBounds(15, 110, 100, 40);
labeldevelopmenttime1.setBounds(458, 110, 100, 40);
developmenttime.setBounds(2, 110, 478, 40);
developmenttime.setForeground(Color.gray);
developmenttime.setBackground(new Color(30, 144, 255));
developmenttime.setOpaque(false);
developmenttime.setBorder(null);
this.add(labeldevelopmenttime);
this.add(labeldevelopmenttime1);
this.getContentPane().add(developmenttime);
developmenttime.addActionListener(this);
quit.setBounds(2, 170, 478, 40);
//quit.setForeground(Color.gray);
quit.setBackground(new Color(30, 144, 255));
quit.setOpaque(false);
quit.setBorder(null);
this.getContentPane().add(quit);
quit.addActionListener(this);
this.add(labelimage);
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource().equals(aboutus)){
JOptionPane.showMessageDialog(this, "该产品由陈锦贤,张志斌,郑丹妮共同开发!");
}
if(e.getSource().equals(developmenttime)){
JOptionPane.showMessageDialog(this, "该产品开发于2019年11月23日");
}
if(e.getSource().equals(backout)){
new Me();
this.dispose();
}
if(e.getSource().equals(quit)){
System.exit(0);
}
}
}