JAVA超市管理系统

目录

 

项目简介

项目框架

项目实现

<用户进行登录界面>

   效果展示

         <用户注册界面>

效果展示

<找回密码界面>

<超市系统的实现界面>

     <主界面>

    <小吃类>

   <蔬菜类>

    <熟食类>

  <男士服装>

   <女士服装>

   <婴儿服装>

  <牛奶类>

  <啤酒类>

  <热饮类>

   效果展示

 


项目简介

*对于客户的信息首先要进行信息录入,

通过自定义注册类来实现客户信息的存入

*账户信息录入成功后即可进行登录,对于登录状态,账户的信息必须要完全正确方可进入相应的超市系统,我们要考虑到用户的个人问题,由于忘记密码引发的问题要进行相应的密码找回设置。

*对于进入超市系统后的界面,首先设置好窗体,对于窗体要实现监听这里用到继承和actionlistener接口的实现,窗体里设置12个按钮分别代表12个不同的货物清单,窗体不设置布局,完全由坐标控制按钮的位置

*对于不同的按钮进行不同的事件监听首先对小吃类进行监听,当客户选择小吃类的时候,相应的给出用户小吃类的类别

*对水果类,熟食类,蔬菜类,进行监听,当客户选择水果类,熟食类,蔬菜类的时候,相应的给出用户水果类,熟食类,蔬菜类的种类及价格

项目框架

项目实现

<用户进行登录界面>

package caoshi.com.cn;


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;


import javax.swing.AbstractButton;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;


public class DengLu extends JFrame implements ActionListener{
JLabel label1,label2,label3,label4,label5;
JTextArea text1,text2,text3;
JButton button1,button2,button3;
DengLu()
{
setTitle("登录");
    setLayout(null);
    setSize(250, 250);
setLocationRelativeTo(null);//设置窗体的位置默认为整个布局的中央
ImageIcon a=new ImageIcon("19.jpg");//设置窗体的背景图片,首先把照片加入到标签里再把标签添加到窗体内
label1=new JLabel(a);
label1.setBounds(0, 0, a.getIconWidth(), a.getIconHeight());//设置标签高度和长度与图片的高度和长度一致
label2=new JLabel("用 户 名:");//提醒用户此处应输入相应的用户名
label2.setBounds(10,30, 70, 40);
text1=new JTextArea();
text1.setBounds(70, 40, 150, 20);//提醒用户此处输入相应的密码信息
label5=new JLabel("密       码:");
label5.setBounds(10,80, 70, 40);
text2=new JTextArea();
text2.setBounds(70, 90, 150, 20);
label3=new JLabel("如未注册请注册");
label3.setBounds(10,120, 200, 40);
button3=new JButton("忘记密码");//设置忘记密码按钮
button3.addActionListener(this);//设置按钮监听
    button3.setBounds(120, 130, 100, 20);
button1=new JButton("登录");
button1.addActionListener(this);
button1.setBounds(70, 160, 60, 30);
button2=new JButton("注册");
button2.addActionListener(this);
button2.setBounds(160, 160, 60, 30);
add(label2);
add(text1);
add(label5);
add(text2);
add(label3);
add(button3);
add(button1);
add(button2);
add(label1,new Integer(Integer.MIN_VALUE));
add(label1);
setVisible(true);
setResizable(false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(text1.getText().isEmpty()==false&&text2.getText().isEmpty()==false)
        {
  if(e.getActionCommand().equals("登录"))
  {
try {
FileReader f=new FileReader("1.txt");//设立FileReader类的对象并创立相应的文档用于读取用户的信息
BufferedReader fr=new BufferedReader(f);//设置文件读取缓冲
String a;
try {
while((a=fr.readLine())!=null)//按行读取相应的文本信息
{
String s=new String(a);
String d[]=s.split("/");//对读取的文件字符串信息流进行分割处理
if(text1.getText().equals(d[0]))
{
  if(text2.getText().equals(d[1]))
{
JOptionPane.showMessageDialog(this,"登录成功");//显示注册登录成功对话框
this.dispose();//关闭登录窗口
new Cahoshi();//登录成功后进入相应的超市系统
}
  else
  {
  JOptionPane.showMessageDialog(this,"密码错误");//登录账户存在密码错误显示密码错误提示框
  this.dispose();//关闭登录窗口
  new Zhaohui();//进入找回密码界面
  }
  }
}
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
   
   }
        }
      if(e.getActionCommand().equals("注册"))
      {
      try {
       this.dispose();
   new Zhuce();//进入注册界面
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
        }
      if(e.getActionCommand().equals("忘记密码"))
      {
      this.dispose();
      new Zhaohui();//进入找回密码界面
      }
}
}

效果展示

 

<用户注册界面>

package caoshi.com.cn;


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;


import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;


public class Zhuce extends JFrame implements ActionListener{//继承窗体类实现Actionlistener接口并重写相应的方法
JLabel label1,label2,label3,label4,label5;
JTextArea text1,text2,text3,text4;
JButton button1,button2;
Zhuce() throws IOException
{
setTitle("注册");
setLayout(null);
setSize(300, 250);
setLocationRelativeTo(null);//设置窗体的位置默认为整个布局的中央
ImageIcon a=new ImageIcon("19.jpg");//设置窗体的背景图片,首先把照片加入到标签里再把标签添加到窗体内
label1=new JLabel(a);
label1.setBounds(0, 0, a.getIconWidth(), a.getIconHeight());//设置标签高度和长度与图片的高度和长度一致
label2=new JLabel("用 户 名:");//设置用户信息录入
label2.setBounds(30,20, 70, 40);
text1=new JTextArea();
text1.setBounds(90, 30, 180, 20);
label3=new JLabel("密       码:");//设置相应的密码录入提示框
label3.setBounds(30,60, 70, 40);
text2=new JTextArea();
text2.setBounds(90, 70, 180, 20);
label4=new JLabel("确认密码:");//再次确认密码,加强账户的安全性
label4.setBounds(30,100, 70, 40);
text3=new JTextArea();
text3.setBounds(90, 110, 180, 20);
label5=new JLabel("手  机  号:");//录入手机号信息为后期的密码找回做铺垫
label5.setBounds(30,140, 70, 40);
text4=new JTextArea();
text4.setBounds(90, 150, 180, 20);
button1=new JButton("注册");
button1.addActionListener(this);
button1.setBounds(90, 180, 80, 30);
button2 =new JButton("重置");//清空对应的文本框的内容
button2.addActionListener(this);//设置相应的按钮事件监听
button2.setBounds(190, 180, 80, 30); 
add(label2);
add(text1);
add(label3);
add(text2);
add(label4);
add(text3);
add(label5);
add(text4);
add(button1);
add(button2);
add(label1,new Integer(Integer.MIN_VALUE));
add(label1);
setVisible(true);
setResizable(false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);//设置窗体关闭时的状态
}
@Override
public void actionPerformed (ActionEvent e){//复写实现接口的对应方法
//TODO Auto-generated method stub
if(text1.getText().isEmpty()==false&&text2.getText().isEmpty()==false&&text3.getText().isEmpty()==false&&text4.getText().isEmpty()==false)

        {
if(e.getActionCommand().equals("注册"))
{
        if(text2.getText().equals(text3.getText())&&text4.getText().isEmpty()==false)
       {
File f=new File("1.txt");//使用File类对象创立录入信息的文本
try
{
         FileWriter fw=new FileWriter(f,true);使用FileWriter类设置用户基本信息的录入
        fw.write(text1.getText());
             fw.write("/");   //将用户基本信息写入相应的文本框     
             fw.write(text2.getText());
             fw.write("/");
             fw.write(text3.getText());
             fw.write("/");
             fw.write(text4.getText());
             fw.write("\n");
        fw.flush();//读入信息缓冲设置
        fw.close();//关闭读入写入信息流
      }catch(IOException e1)
{
e1.printStackTrace();
    }
    JOptionPane.showMessageDialog(this,"注册成功");//注册成功弹出注册成功对话框
text1.setText(null);
text2.setText(null);
text3.setText(null);
this.dispose();
new DengLu();
       }
   else
  {
JOptionPane.showMessageDialog(this,"两次输入密码不一致");//两次密码不一致弹出相应的信息提示框
}
}
if(e.getActionCommand().equals("重置"))//设置按钮事件监听时的处理
{
text1.setText(null);
text2.setText(null);
text3.setText(null);
   
   }
        }
}


}

效果展示

 

<找回密码界面>

package caoshi.com.cn;


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;


import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;


public class Zhaohui extends JFrame implements ActionListener{
JLabel label1,label2,label3,label4,label5;
JTextArea text1,text2,text3;
JButton button1,button2,button3;
Zhaohui()
{
setTitle("找回密码");
    setLayout(null);
    setSize(250, 250);
setLocationRelativeTo(null);//设置窗体的位置默认为整个布局的中央
ImageIcon a=new ImageIcon("19.jpg");//设置窗体的背景图片,首先把照片加入到标签里再把标签添加到窗体内
label1=new JLabel(a);
label1.setBounds(0, 0, a.getIconWidth(), a.getIconHeight());//设置标签高度和长度与图片的高度和长度一致
label2=new JLabel("用 户 名:");
label2.setBounds(10,30, 70, 40);
text1=new JTextArea();
text1.setBounds(70, 40, 150, 20);
label5=new JLabel("手  机  号:");
label5.setBounds(10,80, 70, 40);
text2=new JTextArea();
text2.setBounds(70, 90, 150, 20);
button1=new JButton("确认");
button1.addActionListener(this);
button1.setBounds(70, 160, 60, 30);
button2=new JButton("重置");
button2.addActionListener(this);
button2.setBounds(160, 160, 60, 30);
add(label2);
add(text1);
add(label5);
add(text2);
add(button1);
add(button2);
add(label1,new Integer(Integer.MIN_VALUE));
add(label1);
setVisible(true);
setResizable(false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(text1.getText().isEmpty()==false&&text2.getText().isEmpty()==false)
        {
  if(e.getActionCommand().equals("确认"))
  {
try {
FileReader f=new FileReader("1.txt");//设立FileReader类的对象并创立相应的文档用于读取用户的信息
BufferedReader fr=new BufferedReader(f);//设置文件读取缓冲
String a;
try {
while((a=fr.readLine())!=null)
{
String s=new String(a);
String d[]=s.split("/");//对读取的文件字符串信息流进行分割处理
if(text2.getText().equals(d[3]))
{
  
JOptionPane.showMessageDialog(this,"你的密码为"+d[2]);//用户的账户信息和手机号正确时返回相应的密码
this.dispose();
new DengLu();
}
else
continue;
}
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
   
   }
  if(e.getActionCommand().equals("重置"))//清空相应的文本
  {
  text1.setText(null);
  text2.setText(null);
  }
        }
}
}

<超市系统的实现界面>

 

     <主界面>

package caoshi.com.cn;


import java.awt.Color;
import java.awt.Container;
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.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;


public class Cahoshi extends JFrame implements ActionListener{
JButton b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14;
JLabel label,label1,label2,label3,label4,label5,label6;
JTextArea text;
JDialog dialog,dialog1,dialog2,dialog3,dialog4,dialog5,dialog6,dialog7,dialog8,dialog9,dialog10,dialog11;
JPanel panel;
Cahoshi()
{
setTitle("龙翔超市");
setLayout(null);
setSize(400,400);
setLocationRelativeTo(null);
text=new JTextArea("龙翔超市欢迎您!");
Font font = new Font("宋体",Font.BOLD,40); 
text.setFont(font);
text.setBackground(Color.LIGHT_GRAY);
text.setForeground(Color.blue);
text.setBounds(0, 0,400, 80);
add(text);
b1=new JButton("小吃类");
b1.addActionListener(this);
b1.setBounds(0, 80, 80, 40);
add(b1);
b2=new JButton("蔬菜类");
b2.addActionListener(this);
b2.setBounds(0,160,80, 40);
add(b2);
b3=new JButton("水果类");
b3.addActionListener(this);
b3.setBounds(0, 240,80, 40);
add(b3);
b10=new JButton("熟食类");
b10.addActionListener(this);
b10.setBounds(0, 320,80, 40);
add(b10);
b4=new JButton("果汁类");
b4.addActionListener(this);
b4.setBounds(310,80,80, 40);
add(b4);
b5=new JButton("牛奶类");
b5.addActionListener(this);
b5.setBounds(310,160,80, 40);
add(b5);
b6=new JButton("啤酒类");
b6.addActionListener(this);
b6.setBounds(310,240,80, 40);
add(b6);
b11=new JButton("热饮类");
b11.addActionListener(this);
b11.setBounds(310,320,80, 40);
add(b11);
b7=new JButton("男士服装");
b7.addActionListener(this);
b7.setBounds(150, 80, 100, 40);
add(b7);
b8=new JButton("女士服装");
b8.addActionListener(this);
b8.setBounds(150, 160, 100, 40);
add(b8);
b9=new JButton("儿童服装");
b9.addActionListener(this);
b9.setBounds(150, 240, 100, 40);
add(b9);
b12=new JButton("婴儿服装");
b12.addActionListener(this);
b12.setBounds(150, 320, 100, 40);
add(b12);
ImageIcon img = new ImageIcon("1.jpg");  
     label= new JLabel(img);     
     getLayeredPane().add(label, new Integer(Integer.MIN_VALUE));   
     label.setBounds(0, 0, img.getIconWidth(), img.getIconHeight());    
     add(label);
setVisible(true);
setResizable(false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
@Override

    <小吃类>


public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getActionCommand().equals("小吃类"))
{
dialog=new JDialog();//监听按钮事件当事件出现时弹出相应的对话框
dialog.setBounds(0, 0, 300,250);//设置对话框的位置和大小
panel=new JPanel();//创建面板
panel.setLayout(null);//为面板设置布局,布局为空即不设置具体布局默认位于整个面板中央
b1=new JButton("辣条");
b1.setBounds(0, 0, 80,40);
label2=new JLabel("9元/斤");
label2.setFont(new Font("Dialog",1, 20));//设置标签字体大小,形式,粗细
label2.setForeground(Color.RED);//设置标签字体颜色
label2.setBounds(0, 40, 80, 40);
b2=new JButton("饼干");
b2.setBounds(0, 80, 80,40);
label3=new JLabel("6.5元/斤");
label3.setFont(new Font("Dialog",1, 20));
label3.setForeground(Color.RED);
label3.setBounds(0, 120, 80, 40);
b3=new JButton("瓜子");
b3.setBounds(215, 0, 80,40);
label4=new JLabel("8元/斤");
label4.setFont(new Font("Dialog",1, 20));
label4.setForeground(Color.RED);
label4.setBounds(215,40 , 80, 40);
b4=new JButton("猫耳朵");
b4.setBounds(215, 80, 80,40);
label5=new JLabel("10元/斤");
label5.setFont(new Font("Dialog",1, 20));
label5.setForeground(Color.RED);
label5.setBounds(215,120 , 80, 40);
b5=new JButton("面包");
b5.setBounds(105, 150, 80,40);
label6=new JLabel("12元/斤");
label6.setFont(new Font("Dialog",1, 20));
label6.setForeground(Color.RED);
label6.setBounds(105,190 , 80, 40);
panel.add(b1);
panel.add(label2);
panel.add(b2);
panel.add(label3);
panel.add(b3);
panel.add(label4);
panel.add(b4);
panel.add(label5);
panel.add(b5);
panel.add(label6);
ImageIcon img = new ImageIcon("3.jpg");  
    label1=new JLabel(img);
    label1.setBounds(0, 0, img.getIconWidth(),img.getIconHeight());
    panel.add(label1, new Integer(Integer.MAX_VALUE));
    dialog.add(panel);
    dialog.setVisible(true);
    dialog.setResizable(false); 
}

   <蔬菜类>


if(e.getActionCommand().equals("蔬菜类"))
{
dialog1=new JDialog();
dialog1.setBounds(350, 0, 300, 250);
panel=new JPanel();
panel.setLayout(null);
b1=new JButton("青菜");
b1.setBounds(0,0, 80,40);
label2=new JLabel("2元/斤");
label2.setFont(new Font("Dialog",1, 20));
label2.setForeground(Color.RED);
label2.setBounds(0, 40, 80, 40);
b2=new JButton("芹菜");
b2.setBounds(0, 80, 80,40);
label3=new JLabel("3元/斤");
label3.setFont(new Font("Dialog",1, 20));
label3.setForeground(Color.RED);
label3.setBounds(0, 120, 80, 40);
b3=new JButton("白菜");
b3.setBounds(215, 0, 80,40);
label4=new JLabel("0.8元/斤");
label4.setFont(new Font("Dialog",1, 20));
label4.setForeground(Color.RED);
label4.setBounds(215,40 , 80, 40);
b4=new JButton("土豆");
b4.setBounds(215, 80, 80,40);
label5=new JLabel("2元/斤");
label5.setFont(new Font("Dialog",1, 20));
label5.setForeground(Color.RED);
label5.setBounds(215,120 , 80, 40);
b5=new JButton("小白菜");
b5.setBounds(105, 150, 80,40);
label6=new JLabel("2.3元/斤");
label6.setFont(new Font("Dialog",1, 20));
label6.setForeground(Color.RED);
label6.setBounds(105,190 , 80, 40);
panel.add(b1);
panel.add(label2);
panel.add(b2);
panel.add(label3);
panel.add(b3);
panel.add(label4);
panel.add(b4);
panel.add(label5);
panel.add(b5);
panel.add(label6);
ImageIcon img = new ImageIcon("2.jpg");  
    label1=new JLabel(img);
    label1.setBounds(0, 0, img.getIconWidth(),img.getIconHeight());
    panel.add(label1, new Integer(Integer.MAX_VALUE));
    dialog1.add(panel);
    dialog1.setVisible(true);
    dialog1.setResizable(false);
}

   <水果类>
if(e.getActionCommand().equals("水果类"))
{
dialog2=new JDialog();
dialog2.setBounds(750, 0, 300, 250);
panel=new JPanel();
panel.setLayout(null);
b1=new JButton("苹果");
b1.setBounds(0,0, 80,40);
label2=new JLabel("3.98元/斤");
label2.setFont(new Font("Dialog",1, 20));
label2.setForeground(Color.RED);
label2.setBounds(0, 40, 100, 40);
b2=new JButton("香蕉");
b2.setBounds(0, 80, 80,40);
label3=new JLabel("2.98元/斤");
label3.setFont(new Font("Dialog",1, 20));
label3.setForeground(Color.RED);
label3.setBounds(0, 120, 100, 40);
b3=new JButton("梨");
b3.setBounds(215, 0, 80,40);
label4=new JLabel("2.5元/斤");
label4.setFont(new Font("Dialog",1, 20));
label4.setForeground(Color.RED);
label4.setBounds(215,40 , 80, 40);
b4=new JButton("橘子");
b4.setBounds(215, 80, 80,40);
label5=new JLabel("2元/斤");
label5.setFont(new Font("Dialog",1, 20));
label5.setForeground(Color.RED);
label5.setBounds(215,120 , 80, 40);
b5=new JButton("火龙果");
b5.setBounds(105, 150, 80,40);
label6=new JLabel("3.5元/斤");
label6.setFont(new Font("Dialog",1, 20));
label6.setForeground(Color.RED);
label6.setBounds(105,190 , 80, 40);
panel.add(b1);
panel.add(label2);
panel.add(b2);
panel.add(label3);
panel.add(b3);
panel.add(label4);
panel.add(b4);
panel.add(label5);
panel.add(b5);
panel.add(label6);
ImageIcon img = new ImageIcon("4.jpg");  
    label1=new JLabel(img);
    label1.setBounds(0, 0, img.getIconWidth(),img.getIconHeight());
    panel.add(label1, new Integer(Integer.MAX_VALUE));
    dialog2.add(panel);
    dialog2.setVisible(true);
    dialog2.setResizable(false);
}

    <熟食类>


if(e.getActionCommand().equals("熟食类"))
{
dialog3=new JDialog();
dialog3.setBounds(1150, 0, 300, 250);
panel=new JPanel();
panel.setLayout(null);
b1=new JButton("鸭脖");
b1.setBounds(0,0, 80,40);
label2=new JLabel("10元/斤");
label2.setFont(new Font("Dialog",1, 20));
label2.setForeground(Color.RED);
label2.setBounds(0, 40, 80, 40);
b2=new JButton("熟牛肉");
b2.setBounds(0, 80, 80,40);
label3=new JLabel("28元/斤");
label3.setFont(new Font("Dialog",1, 20));
label3.setForeground(Color.RED);
label3.setBounds(0, 120, 80, 40);
b3=new JButton("猪头肉");
b3.setBounds(215, 0, 80,40);
label4=new JLabel("20元/斤");
label4.setFont(new Font("Dialog",1, 20));
label4.setForeground(Color.RED);
label4.setBounds(215,40 , 80, 40);
b4=new JButton("腊肠");
b4.setBounds(215, 80, 80,40);
label5=new JLabel("12元/斤");
label5.setFont(new Font("Dialog",1, 20));
label5.setForeground(Color.RED);
label5.setBounds(215,120 , 80, 40);
b5=new JButton("酱驴肉");
b5.setBounds(105, 150, 80,40);
label6=new JLabel("18.9元/斤");
label6.setFont(new Font("Dialog",1, 20));
label6.setForeground(Color.RED);
label6.setBounds(105,190 , 80, 40);
panel.add(b1);
panel.add(label2);
panel.add(b2);
panel.add(label3);
panel.add(b3);
panel.add(label4);
panel.add(b4);
panel.add(label5);
panel.add(b5);
panel.add(label6);
ImageIcon img = new ImageIcon("8.jpg");  
    label1=new JLabel(img);
    label1.setBounds(0, 0, img.getIconWidth(),img.getIconHeight());
    panel.add(label1, new Integer(Integer.MAX_VALUE));
    dialog3.add(panel);
    dialog3.setVisible(true);
    dialog3.setResizable(false);
}

  <男士服装>


if(e.getActionCommand().equals("男士服装"))
{
dialog4=new JDialog();
dialog4.setBounds(0, 300, 300,250);
panel=new JPanel();
panel.setLayout(null);
b1=new JButton("休闲裤");
b1.setBounds(0, 0, 80,40);
label2=new JLabel("100元");
label2.setFont(new Font("Dialog",1, 20));
label2.setForeground(Color.RED);
label2.setBounds(0, 40, 80, 40);
b2=new JButton("运动裤");
b2.setBounds(0, 80, 80,40);
label3=new JLabel("95元");
label3.setFont(new Font("Dialog",1, 20));
label3.setForeground(Color.RED);
label3.setBounds(0, 120, 80, 40);
b3=new JButton("寸衫");
b3.setBounds(215, 0, 80,40);
label4=new JLabel("75元");
label4.setFont(new Font("Dialog",1, 20));
label4.setForeground(Color.RED);
label4.setBounds(215,40 , 80, 40);
b4=new JButton("外套");
b4.setBounds(215, 80, 80,40);
label5=new JLabel("128元");
label5.setFont(new Font("Dialog",1, 20));
label5.setForeground(Color.RED);
label5.setBounds(215,120 , 80, 40);
b5=new JButton("卫衣");
b5.setBounds(105, 150, 80,40);
label6=new JLabel("100元");
label6.setFont(new Font("Dialog",1, 20));
label6.setForeground(Color.RED);
label6.setBounds(105,190 , 80, 40);
panel.add(b1);
panel.add(label2);
panel.add(b2);
panel.add(label3);
panel.add(b3);
panel.add(label4);
panel.add(b4);
panel.add(label5);
panel.add(b5);
panel.add(label6);
ImageIcon img = new ImageIcon("7.jpg");  
    label1=new JLabel(img);
    label1.setBounds(0, 0, img.getIconWidth(),img.getIconHeight());
    panel.add(label1, new Integer(Integer.MAX_VALUE));
    dialog4.add(panel);
    dialog4.setVisible(true);
    dialog4.setResizable(false);
}

   <女士服装>


if(e.getActionCommand().equals("女士服装"))
{
dialog5=new JDialog();
dialog5.setBounds(350,300, 300, 250);
panel=new JPanel();
panel.setLayout(null);
b1=new JButton("毛衣");
b1.setBounds(0,0, 80,40);
label2=new JLabel("89元");
label2.setFont(new Font("Dialog",1, 20));
label2.setForeground(Color.RED);
label2.setBounds(0, 40, 80, 40);
b2=new JButton("阔腿裤");
b2.setBounds(0, 80, 80,40);
label3=new JLabel("105元");
label3.setFont(new Font("Dialog",1, 20));
label3.setForeground(Color.RED);
label3.setBounds(0, 120, 80, 40);
b3=new JButton("牛仔裤");
b3.setBounds(215, 0, 80,40);
label4=new JLabel("90元");
label4.setFont(new Font("Dialog",1, 20));
label4.setForeground(Color.RED);
label4.setBounds(215,40 , 80, 40);
b4=new JButton("羽绒服");
b4.setBounds(215, 80, 80,40);
label5=new JLabel("800元");
label5.setFont(new Font("Dialog",1, 20));
label5.setForeground(Color.RED);
label5.setBounds(215,120 , 80, 40);
b5=new JButton("外套");
b5.setBounds(105, 150, 80,40);
label6=new JLabel("70元");
label6.setFont(new Font("Dialog",1, 20));
label6.setForeground(Color.RED);
label6.setBounds(105,190 , 80, 40);
panel.add(b1);
panel.add(label2);
panel.add(b2);
panel.add(label3);
panel.add(b3);
panel.add(label4);
panel.add(b4);
panel.add(label5);
panel.add(b5);
panel.add(label6);
ImageIcon img = new ImageIcon("9.jpg");  
    label1=new JLabel(img);
    label1.setBounds(0, 0, img.getIconWidth(),img.getIconHeight());
    panel.add(label1, new Integer(Integer.MAX_VALUE));
    dialog5.add(panel);
    dialog5.setVisible(true);
    dialog5.setResizable(false);
}

  <儿童服装>
if(e.getActionCommand().equals("儿童服装"))
{
dialog6=new JDialog();
dialog6.setBounds(750, 300, 300, 250);
panel=new JPanel();
panel.setLayout(null);
b1=new JButton("T恤");
b1.setBounds(0,0, 80,40);
label2=new JLabel("50元");
label2.setFont(new Font("Dialog",1, 20));
label2.setForeground(Color.RED);
label2.setBounds(0, 40, 80, 40);
b2=new JButton("裤子");
b2.setBounds(0, 80, 80,40);
label3=new JLabel("35元");
label3.setFont(new Font("Dialog",1, 20));
label3.setForeground(Color.RED);
label3.setBounds(0, 120, 80, 40);
b3=new JButton("套装");
b3.setBounds(215, 0, 80,40);
label4=new JLabel("230元");
label4.setFont(new Font("Dialog",1, 20));
label4.setForeground(Color.RED);
label4.setBounds(215,40 , 80, 40);
b4=new JButton("外套");
b4.setBounds(215, 80, 80,40);
label5=new JLabel("89元");
label5.setFont(new Font("Dialog",1, 20));
label5.setForeground(Color.RED);
label5.setBounds(215,120 , 80, 40);
b5=new JButton("秋衣");
b5.setBounds(105, 150, 80,40);
label6=new JLabel("30元");
label6.setFont(new Font("Dialog",1, 20));
label6.setForeground(Color.RED);
label6.setBounds(105,190 , 80, 40);
panel.add(b1);
panel.add(label2);
panel.add(b2);
panel.add(label3);
panel.add(b3);
panel.add(label4);
panel.add(b4);
panel.add(label5);
panel.add(b5);
panel.add(label6);
ImageIcon img = new ImageIcon("10.jpg");  
    label1=new JLabel(img);
    label1.setBounds(0, 0, img.getIconWidth(),img.getIconHeight());
    panel.add(label1, new Integer(Integer.MAX_VALUE));
    dialog6.add(panel);
    dialog6.setVisible(true);
    dialog6.setResizable(false);
}

   <婴儿服装>


if(e.getActionCommand().equals("婴儿服装"))
{
dialog7=new JDialog();
dialog7.setBounds(1150, 300, 300, 250);
panel=new JPanel();
panel.setLayout(null);
b1=new JButton("婴儿套装");
b1.setBounds(0,0, 120,40);
label2=new JLabel("75元");
label2.setFont(new Font("Dialog",1, 20));
label2.setForeground(Color.RED);
label2.setBounds(0, 40, 80, 40);
b2=new JButton("婴儿连体衣");
b2.setBounds(0, 80, 120,40);
label3=new JLabel("119元");
label3.setFont(new Font("Dialog",1, 20));
label3.setForeground(Color.RED);
label3.setBounds(0, 120, 80, 40);
b3=new JButton("婴儿背带裤");
b3.setBounds(215, 0, 120,40);
label4=new JLabel("95元");
label4.setFont(new Font("Dialog",1, 20));
label4.setForeground(Color.RED);
label4.setBounds(215,40 , 80, 40);
b4=new JButton("婴儿羽绒服");
b4.setBounds(215, 80, 120,40);
label5=new JLabel("400元");
label5.setFont(new Font("Dialog",1, 20));
label5.setForeground(Color.RED);
label5.setBounds(215,120 , 80, 40);
b5=new JButton("婴儿睡衣");
b5.setBounds(105, 150, 120,40);
label6=new JLabel("74元");
label6.setFont(new Font("Dialog",1, 20));
label6.setForeground(Color.RED);
label6.setBounds(105,190 , 80, 40);
panel.add(b1);
panel.add(label2);
panel.add(b2);
panel.add(label3);
panel.add(b3);
panel.add(label4);
panel.add(b4);
panel.add(label5);
panel.add(b5);
panel.add(label6);
ImageIcon img = new ImageIcon("11.jpg");  
    label1=new JLabel(img);
    label1.setBounds(0, 0, img.getIconWidth(),img.getIconHeight());
    panel.add(label1, new Integer(Integer.MAX_VALUE));
    dialog7.add(panel);
    dialog7.setVisible(true);
    dialog7.setResizable(false);
}

  <果汁类>
if(e.getActionCommand().equals("果汁类"))
{
dialog8=new JDialog();
dialog8.setBounds(0, 600, 300,250);
panel=new JPanel();
panel.setLayout(null);
b1=new JButton("橙汁");
b1.setBounds(0, 0, 80,40);
label2=new JLabel("10元/杯");
label2.setFont(new Font("Dialog",1, 20));
label2.setForeground(Color.RED);
label2.setBounds(0, 40, 80, 40);
b2=new JButton("苹果汁");
b2.setBounds(0, 80, 80,40);
label3=new JLabel("8元/杯");
label3.setFont(new Font("Dialog",1, 20));
label3.setForeground(Color.RED);
label3.setBounds(0, 120, 80, 40);
b3=new JButton("西瓜汁");
b3.setBounds(215, 0, 80,40);
label4=new JLabel("4元/杯");
label4.setFont(new Font("Dialog",1, 20));
label4.setForeground(Color.RED);
label4.setBounds(215,40 , 80, 40);
b4=new JButton("甘蔗汁");
b4.setBounds(215, 80, 80,40);
label5=new JLabel("5元/杯");
label5.setFont(new Font("Dialog",1, 20));
label5.setForeground(Color.RED);
label5.setBounds(215,120 , 80, 40);
b5=new JButton("葡萄汁");
b5.setBounds(105, 150, 80,40);
label6=new JLabel("8元/杯");
label6.setFont(new Font("Dialog",1, 20));
label6.setForeground(Color.RED);
label6.setBounds(105,190 , 80, 40);
panel.add(b1);
panel.add(label2);
panel.add(b2);
panel.add(label3);
panel.add(b3);
panel.add(label4);
panel.add(b4);
panel.add(label5);
panel.add(b5);
panel.add(label6);
ImageIcon img = new ImageIcon("12.jpg");  
    label1=new JLabel(img);
    label1.setBounds(0, 0, img.getIconWidth(),img.getIconHeight());
    panel.add(label1, new Integer(Integer.MAX_VALUE));
    dialog8.add(panel);
    dialog8.setVisible(true);
    dialog8.setResizable(false);
    
}

  <牛奶类>


if(e.getActionCommand().equals("牛奶类"))
{
dialog9=new JDialog();
dialog9.setBounds(350,600, 300, 250);
panel=new JPanel();
panel.setLayout(null);
b1=new JButton("娃哈哈");
b1.setBounds(0,0, 80,40);
label2=new JLabel("30元/箱");
label2.setFont(new Font("Dialog",1, 20));
label2.setForeground(Color.RED);
label2.setBounds(0, 40, 80, 40);
b2=new JButton("特仑苏");
b2.setBounds(0, 80, 80,40);
label3=new JLabel("40元/箱");
label3.setFont(new Font("Dialog",1, 20));
label3.setForeground(Color.RED);
label3.setBounds(0, 120, 80, 40);
b3=new JButton("纯牛奶");
b3.setBounds(215, 0, 80,40);
label4=new JLabel("45元/箱");
label4.setFont(new Font("Dialog",1, 20));
label4.setForeground(Color.RED);
label4.setBounds(215,40 , 80, 40);
b4=new JButton("酸奶");
b4.setBounds(215, 80, 80,40);
label5=new JLabel("75元/箱");
label5.setFont(new Font("Dialog",1, 20));
label5.setForeground(Color.RED);
label5.setBounds(215,120 , 80, 40);
b5=new JButton("安慕希");
b5.setBounds(105, 150, 80,40);
label6=new JLabel("70元/箱");
label6.setFont(new Font("Dialog",1, 20));
label6.setForeground(Color.RED);
label6.setBounds(105,190 , 80, 40);
panel.add(b1);
panel.add(label2);
panel.add(b2);
panel.add(label3);
panel.add(b3);
panel.add(label4);
panel.add(b4);
panel.add(label5);
panel.add(b5);
panel.add(label6);
ImageIcon img = new ImageIcon("13.jpg");  
    label1=new JLabel(img);
    label1.setBounds(0, 0, img.getIconWidth(),img.getIconHeight());
    panel.add(label1, new Integer(Integer.MAX_VALUE));
    dialog9.add(panel);
    dialog9.setVisible(true);
    dialog9.setResizable(false);
}

  <啤酒类>


if(e.getActionCommand().equals("啤酒类"))
{
dialog10=new JDialog();
dialog10.setBounds(750, 600, 300, 250);
panel=new JPanel();
panel.setLayout(null);
b1=new JButton("雪花啤酒");
b1.setBounds(0,0, 120,40);
label2=new JLabel("4元/瓶");
label2.setFont(new Font("Dialog",1, 20));
label2.setForeground(Color.RED);
label2.setBounds(0, 40, 80, 40);
b2=new JButton("青岛啤酒");
b2.setBounds(0, 80, 120,40);
label3=new JLabel("4元/瓶");
label3.setFont(new Font("Dialog",1, 20));
label3.setForeground(Color.RED);
label3.setBounds(0, 120, 80, 40);
b3=new JButton("燕京啤酒");
b3.setBounds(215, 0, 120,40);
label4=new JLabel("3.5元/瓶");
label4.setFont(new Font("Dialog",1, 20));
label4.setForeground(Color.RED);
label4.setBounds(215,40 , 80, 40);
b4=new JButton("果啤");
b4.setBounds(215, 80, 120,40);
label5=new JLabel("7元/瓶");
label5.setFont(new Font("Dialog",1, 20));
label5.setForeground(Color.RED);
label5.setBounds(215,120 , 80, 40);
b5=new JButton("三得利啤酒");
b5.setBounds(105, 150, 120,40);
label6=new JLabel("3元/瓶");
label6.setFont(new Font("Dialog",1, 20));
label6.setForeground(Color.RED);
label6.setBounds(105,190 , 80, 40);
panel.add(b1);
panel.add(label2);
panel.add(b2);
panel.add(label3);
panel.add(b3);
panel.add(label4);
panel.add(b4);
panel.add(label5);
panel.add(b5);
panel.add(label6);
ImageIcon img = new ImageIcon("14.jpg");  
    label1=new JLabel(img);
    label1.setBounds(0, 0, img.getIconWidth(),img.getIconHeight());
    panel.add(label1, new Integer(Integer.MAX_VALUE));
    dialog10.add(panel);
    dialog10.setVisible(true);
    dialog10.setResizable(false);
}

  <热饮类>


if(e.getActionCommand().equals("热饮类"))
{
this.dispose();
dialog11=new JDialog();
dialog11.setBounds(1150, 600, 300, 250);
panel=new JPanel();
panel.setLayout(null);
b1=new JButton("珍珠奶茶");
b1.setBounds(0,0, 120,40);
label2=new JLabel("5元/杯");
label2.setFont(new Font("Dialog",1, 20));
label2.setForeground(Color.RED);
label2.setBounds(0, 40, 80, 40);
b2=new JButton("红茶");
b2.setBounds(0, 80, 120,40);
label3=new JLabel("2元/杯");
label3.setFont(new Font("Dialog",1, 20));
label3.setForeground(Color.RED);
label3.setBounds(0, 120, 80, 40);
b3=new JButton("茉莉花茶");
b3.setBounds(215, 0, 120,40);
label4=new JLabel("2.5元/瓶");
label4.setFont(new Font("Dialog",1, 20));
label4.setForeground(Color.RED);
label4.setBounds(215,40 , 80, 40);
b4=new JButton("红豆奶茶");
b4.setBounds(215, 80, 120,40);
label5=new JLabel("6元/杯");
label5.setFont(new Font("Dialog",1, 20));
label5.setForeground(Color.RED);
label5.setBounds(215,120 , 80, 40);
b5=new JButton("经典咖啡");
b5.setBounds(105, 150, 120,40);
label6=new JLabel("7元/杯");
label6.setFont(new Font("Dialog",1, 20));
label6.setForeground(Color.RED);
label6.setBounds(105,190 , 80, 40);
panel.add(b1);
panel.add(label2);
panel.add(b2);
panel.add(label3);
panel.add(b3);
panel.add(label4);
panel.add(b4);
panel.add(label5);
panel.add(b5);
panel.add(label6);
ImageIcon img = new ImageIcon("15.jpg");  
    label1=new JLabel(img);
    label1.setBounds(0, 0, img.getIconWidth(),img.getIconHeight());
    panel.add(label1, new Integer(Integer.MAX_VALUE));
    dialog11.add(panel);
    dialog11.setVisible(true);
    dialog11.setResizable(false);
}
}
}

   效果展示

 

 

  • 64
    点赞
  • 426
    收藏
    觉得还不错? 一键收藏
  • 105
    评论
评论 105
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值