weixin_52513228 2021-07-02 14:20 采纳率: 100%
浏览 222
已采纳

Java停车场计费管理系统

有人能帮我解决一下吗?

img
感激不尽

  • 写回答

2条回答 默认 最新

  • 关注
    package T3;
    
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.FlowLayout;
    import java.awt.Graphics;
    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.JPanel;
    
    public class Car extends JFrame implements ActionListener{
    
        JPanel southPanel;
        JButton btnIn,btnOut;
        CQueue queue;
        ImagePanel imagePanel;
        int index=-1;
        boolean flag=false;
        public Car() {
            super("家家乐停车场...");
            queue = new CQueue();
            java.awt.Container c = getContentPane();
            southPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
            imagePanel = new ImagePanel();
            btnIn = new JButton("入库");
            btnOut = new JButton("出库");
            btnIn.addActionListener(this);
            btnOut.addActionListener(this);
            southPanel.add(btnIn);
            southPanel.add(btnOut);
            c.add(imagePanel);
            c.add(southPanel,BorderLayout.SOUTH);
            setSize(1250, 250);
            setVisible(true);
            setLocationRelativeTo(null);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        }
        public void actionPerformed(ActionEvent e) {
            if(e.getSource()==btnIn){
                flag=true;
                index = queue.inQueue("1");
                imagePanel.repaint();
            }else if(e.getSource()==btnOut){
                flag=false;
                index=queue.outQueue();
                imagePanel.repaint();
            }
        }
        //内部类
        class ImagePanel extends JPanel{
            ImageIcon[] images ={
                    new ImageIcon("qq.jpg"),
                    new ImageIcon("clear.jpg")
            };
            int width=126; //图片宽
            int height=131;//图片的高
            @Override
            public void paint(Graphics g) {
                if(index>=0){
                    if(flag){
                        g.drawImage(images[0].getImage(), index*width, 0,width,height,Color.BLUE, this);
                    }else{
                        g.drawImage(images[1].getImage(), index*width, 0,width,height,Color.BLUE, this);
                    }
                }
            }
        }
        public static void main(String[] args) {
            new Car();
        }
    }
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效