Java Swing(C/S模式)特效雨滴系统界面

                   



 


调节不同参数,生成不同特效:

  





                                        ------------------界面截图--------------------- 

package org.jd.data.netty.big.window.chat.frame.ui.controller.center;
import lombok.extern.slf4j.Slf4j;
import java.util.concurrent.*;


/**
 * 设计模式: 单例模式
 *  * 自定义线程池: 实现业务需求:
 *  * 可以获取线程池内部细节,对排查程序故障有很大的好处
 * <p>@Description: 自定义线程池</p>
 * <p>@Copyright: Copyright (c)2,023</p>
 * <p>@Company: 北京惠农科技有限公司</p>
 * <P>@Created Date :2023年03月19日</P>
 * <P>@version 1.0
 * <p>@author yh19166</p>
 */
@Slf4j
public final class SSOCustomerThreadPoolExecutor extends ThreadPoolExecutor {

    private static final int corePoolSize = 4;
    private static final long keepAliveTime = 10;
    private static final int maximumPoolSize = 10;
    private static final TimeUnit unit = TimeUnit.MILLISECONDS;  // 微秒
    private static final BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>(10); // 队列容量
    private static final ThreadFactory threadFactory = new SSOCustomerThreadFactory();

    private static class SSOCustomerThreadPoolExecutorHandler {
        private static SSOCustomerThreadPoolExecutor newInstance = new SSOCustomerThreadPoolExecutor(maximumPoolSize * 2, threadFactory);
    }

    public static SSOCustomerThreadPoolExecutor newInstance() {
        return SSOCustomerThreadPoolExecutor.SSOCustomerThreadPoolExecutorHandler.newInstance;
    }


    private SSOCustomerThreadPoolExecutor(int maximumPoolSize, ThreadFactory threadFactory) {
        super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory,new SSORejectedExecutionHandler());
    }

    @Override
    protected void beforeExecute(Thread task, Runnable r) {
        Runtime runtime = Runtime.getRuntime();
        int cupNum = runtime.availableProcessors();// 获取可以的CUP数量
        long freeMemory = runtime.freeMemory(); // 空闲内存 kb;
        long maxMemory = runtime.maxMemory();
        long totalMemory = runtime.totalMemory();
        System.out.println("current name: " + task.getName() + " | beforeExecute 可以的CPU数量: " + cupNum + " | 空闲内存: " + freeMemory + " | 最大内存: " + maxMemory + "  | 总内存: " + totalMemory);
    }

    @Override
    protected void afterExecute(Runnable task, Throwable t) {
        System.out.println("afterExecute Thread name : " + task.getClass().getSimpleName()+ " | current thread status :" + Thread.currentThread().getState()
                + " current thread id : " + Thread.currentThread().getId() + " | afterExecute poolSize : "
                + this.getPoolSize() + " | threadPool task num : "
                + this.getTaskCount() + " | finished task num: "
                + this.getCompletedTaskCount() + " | not finished task num: " + (this.getTaskCount() - this.getCompletedTaskCount()));
        System.out.println("============================================================================================================================================");
        Runtime runtime = Runtime.getRuntime();
        int cupNum = runtime.availableProcessors();// 获取可以的CUP数量
        long freeMemory = runtime.freeMemory(); // 空闲内存 kb;
        long maxMemory = runtime.maxMemory();
        long totalMemory = runtime.totalMemory();
        try {
            System.out.println("current name: " + task.getClass().newInstance() + " | beforeExecute 可以的CPU数量: " + cupNum + " | 空闲内存: " + freeMemory + " | 最大内存: " + maxMemory + "  | 总内存: " + totalMemory);
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        System.out.println("============================================================================================================================================");
    }


}

  





package org.jd.data.netty.big.window.chat.frame.ui.room.main;

import com.sun.awt.AWTUtilities;
import org.jd.data.netty.big.window.chat.frame.ui.controller.center.SSOControllerCenterManager;
import org.jd.data.netty.big.window.chat.frame.ui.room.custom.RJButton;
import org.jd.data.netty.big.window.chat.frame.ui.room.metal.SSOSumMetalTool;
import org.jd.data.netty.big.window.chat.frame.ui.room.system.SSOSystemIni;
import javax.swing.*;
import javax.swing.border.LineBorder;
import java.awt.*;
import java.awt.event.*;


/**
 * 窗体显示风格
 * 
 * 酒店主窗体
 */
public class HotelMainFrame extends JFrame implements ActionListener, MouseListener, Runnable {

    public static String userId;
    private static String puiLi;
    public static JLabel jLabelA;
    public static JLabel jLabelB;
    private static String clue = "   提示:  ";
    private static String face = "     当前操作界面 :  ";

    // 声明与菜单相关的组件
    private JMenuBar jMenuBar;
    private JMenu jMenu1;
    private JMenu jMenu2;
    private JMenu jMenu3;
    private JMenu jMenu4;
    private JMenu jMenu5;
    private JMenu jMenu6;
    private JMenu jMenu7;
    private JMenu jMenu8;
    private JMenu jMenu9;
    private JMenu jMenu10;
    // 来宾登录
    private JMenuItem jMenuItem1;
    private JMenuItem jMenuItem2;
    private JMenuItem jMenuItem3;
    private JMenuItem jMenuItem4;
    private JMenuItem jMenuItem5;
    private JMenuItem jMenuItem6;
    private JMenuItem jMenuItem7;
    private JMenuItem jMenuItem8;
    private JMenuItem jMenuItem9;
    // 收银结算
    private JMenuItem jMenuItem21;
    private JMenuItem jMenuItem22;
    private JMenuItem jMenuItem23;
    private JMenuItem jMenuItem24;
    private JMenuItem jMenuItem25;
    // 系统维护
    private JMenuItem jMenuItem31;
    private JMenuItem jMenuItem32;

    private JMenuItem jMenuItem34;

    // 声明与工具栏相关的组件
    private JToolBar jToolBar;
    private RJButton jButton1;
    private RJButton jButton2;
    /*private JButton jButton3;*/
    private RJButton jButton4;
    private RJButton jButton5;
    private RJButton jButton6;
    private RJButton jButton7;
    private RJButton jButton8;
    private RJButton jButton9;
    private RJButton jButtonA;

    // 声明与分割面板相关的组件
    private JSplitPane jSplitPaneMain;
    private JSplitPane jSplitPaneLeft;
    private JSplitPane jSplitPaneRight;
    //模块接口
    private JPanel panelMain;
    private JPanel bott;
    private JPanel jp2;
    private JPanel jp3;
    private JPanel jp4;
    // 主窗口左边面板
    private HotelMainLeftTopPanel jp1;

    //功能提示
    private String toolTip[] = {
            "零散宾客入住登记                      ",
            "团体入住登记                        ",
            "关于本软件的支持信息                    ",
            "宾客退房结算                        ",
            "为宾客预订房间                       ",
            "查询营业情况                        ",
            "为酒店固定客户设置参数                   ",
            "设置系统的网络连接方式                   ",
            "设置系统参数                        ",
            "返回Windows                       "
    };

    public HotelMainFrame(String us, String pu) {
        super("惠农数字化酒店管理系统");
        // 操作员名称
        userId = us;
        puiLi = pu;
        // 主面板
        panelMain = new JPanel(new BorderLayout());
        // 制作菜单
        buildMenuBar();
        // 制作工具栏
        buildToolBar();
        // 制作分割面板
        buildSPanelMain();
        // 制作窗口底部信息框
        buildBottom();
        // 加入组件到主面板

        panelMain.add("North", jToolBar);
        // 加入窗口底端信息框
        panelMain.add("South", bott);
        // 加入分割面;
        panelMain.add("Center", jSplitPaneMain);

        // 加入菜单栏
        this.setJMenuBar(jMenuBar);

        // 加入监听器
        addListener();

        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                quit();
            }
        });
        // 设置内容面板
        Container container = this.getContentPane();
        container.add(panelMain);
        this.setBounds(2, 2, 1400, 800);
        //居中显示
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        // 设置最小显示尺寸
        this.setMinimumSize(new Dimension(1400, 800));
        this.setVisible(true);
        // 使用自定义线程池来管理
        SSOControllerCenterManager serverExecutor = SSOControllerCenterManager.newInstance();
        serverExecutor.getExecutorService().submit(this);
    }

    private void quit() {
        String msg = "您 现 在 要 关 闭 系 统 吗 ?";
        int flag = JOptionPane.showConfirmDialog(this, msg, "提示", JOptionPane.YES_NO_OPTION);
        if (flag == JOptionPane.YES_OPTION) {
            //Journal.writeJournalInfo(userId, "退出本系统", Journal.TYPE_LG);//记录操作日志
            this.setVisible(false);
            System.exit(0);
        }
    }

    private void addListener() {
        //来宾登记
        jMenuItem1.addActionListener(this);
        jMenuItem2.addActionListener(this);
        jMenuItem3.addActionListener(this);
        jMenuItem4.addActionListener(this);
        jMenuItem5.addActionListener(this);
        jMenuItem6.addActionListener(this);
        jMenuItem7.addActionListener(this);
        jMenuItem8.addActionListener(this);
        jMenuItem9.addActionListener(this);
        //收银结算
        jMenuItem21.addActionListener(this);
        jMenuItem22.addActionListener(this);
        jMenuItem23.addActionListener(this);
        jMenuItem24.addActionListener(this);
        jMenuItem25.addActionListener(this);
        //系统维护
        jMenuItem31.addActionListener(this);
        jMenuItem32.addActionListener(this);

        jMenuItem34.addActionListener(this);
        //按键加动作监听
        jButton1.addActionListener(this);
        jButton2.addActionListener(this);
        /*jButton3.addActionListener (this);*/
        jButton4.addActionListener(this);
        jButton5.addActionListener(this);
        jButton6.addActionListener(this);
        jButton7.addActionListener(this);
        jButton8.addActionListener(this);
        jButton9.addActionListener(this);
        jButtonA.addActionListener(this);
        //按键加鼠标监听
        jButton1.addMouseListener(this);
        jButton2.addMouseListener(this);
        jButton4.addMouseListener(this);
        jButton5.addMouseListener(this);
        jButton6.addMouseListener(this);
        jButton7.addMouseListener(this);
        jButton8.addMouseListener(this);
        jButton9.addMouseListener(this);
        jButtonA.addMouseListener(this);
    }

    // 制作窗口底部信息框
    private void buildBottom() {
        JLabel jLabel1 = new JLabel("    惠 农 数 字 化 酒 店 管 理 系 统    ");
        JLabel jLabel2 = new JLabel("    当前操作员 :  " + userId + "                  ");
        jLabelA = new JLabel(clue + "请选择功能项 ...                       ");
        jLabelB = new JLabel(face + "惠 农 数 字 化 酒 店 管 理 系 统   ");
        // 给标签添加外边框
        jLabelA.setBorder(new LineBorder(new Color(87, 87, 47)));
        jLabelB.setBorder(new LineBorder(new Color(87, 87, 47)));
        jLabel1.setBorder(new LineBorder(new Color(87, 87, 47)));
        jLabel2.setBorder(new LineBorder(new Color(87, 87, 47)));

        // 设置底部面板布局方式为流式布局;组件基左,水平和竖直间隙为2
        bott = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 2));
        bott.add(jLabel1); // 组件显示与添加顺序有关系
        bott.add(jLabelA);
        bott.add(jLabelB);
        bott.add(jLabel2);
    }

    // 制作主面板
    private void buildSPanelMain() {
        // 左侧顶部的面板
        jp1 = new HotelMainLeftTopPanel();
        // 左下面板;快速通道
        jp2 = new HotelMainLeftBottomPanel();
        //  /
        jp3 = new HotelMainRightTopPanel();
        // 右下面板, 消费信息表
        jp4 = new HotelMainRightBottomPanel();


        // 声明分割面板
        jSplitPaneLeft = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, jp1, jp2);
        jSplitPaneRight = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, jp3, jp4);
        jSplitPaneMain = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, jSplitPaneLeft, jSplitPaneRight);

        // 设置面板的最小尺寸
        jp1.setMinimumSize(new Dimension(157, 450));
        jp2.setMinimumSize(new Dimension(157, 94));
        jp3.setMinimumSize(new Dimension(875, 300));
        jp4.setMinimumSize(new Dimension(875, 94));


        jSplitPaneRight.setMinimumSize(new Dimension(875, 565));

        // 设置分割条是否有伸缩键
        jSplitPaneMain.setOneTouchExpandable(true);
        jSplitPaneRight.setOneTouchExpandable(true);

        // 设置各面板的初始尺寸
        jSplitPaneMain.setDividerLocation(160);
        jSplitPaneLeft.setDividerLocation(450);
        jSplitPaneRight.setDividerLocation(450);
        // 设置分割条宽度
        jSplitPaneMain.setDividerSize(10);
        jSplitPaneLeft.setDividerSize(23);
        jSplitPaneRight.setDividerSize(23);

    }

    // 制作工具栏
    private void buildToolBar() {
        jToolBar = new JToolBar();

        //URL url1 = ClassLoader.getSystemResource("image/hotel/bar/tool/m01.gif");
        ClassLoader classLoader = RJButton.class.getClassLoader();
        String basePicPath = "image/hotel/bar/tool/"; // 后期放到配置文件中去
        //制作按键
        jButton1 = new RJButton(classLoader.getResource(basePicPath + "m01.gif").getPath(), "  个人订房  ", "零散宾客入住登记", true);
        jButton2 = new RJButton(classLoader.getResource(basePicPath + "m02.gif").getPath(), "  多人订房  ", "团体入住登记", true);
        jButton4 = new RJButton(classLoader.getResource(basePicPath + "m04.gif").getPath(), "  旅客结帐  ", "宾客退房结算", true);
        jButton5 = new RJButton(classLoader.getResource(basePicPath + "m05.gif").getPath(), "  预订房间  ", "为宾客预定房间", true);
        jButton6 = new RJButton(classLoader.getResource(basePicPath + "m06.gif").getPath(), "  营业查询  ", "查询营业情况", true);
        jButton7 = new RJButton(classLoader.getResource(basePicPath + "m07.gif").getPath(), "  客户管理  ", "为酒店固定客户设置", true);
        jButton8 = new RJButton(classLoader.getResource(basePicPath + "m08.gif").getPath(), "  网络设置  ", "设置连接方式", true);
        jButton9 = new RJButton(classLoader.getResource(basePicPath + "m09.gif").getPath(), "  系统设置  ", "设置系统参数", true);
        jButtonA = new RJButton(classLoader.getResource(basePicPath + "m10.gif").getPath(), "  退出系统  ", "返回Windows", true);
        // 把按键添加如工具栏
        /**
         * Appends a separator of default size to the end of the tool bar.
         * The default size is determined by the current look and feel.
         */
        jToolBar.addSeparator(); // 添加分割线;就是一小段空白小区域
        jToolBar.add(jButton1);
        jToolBar.add(jButton2);
        jToolBar.addSeparator();
        jToolBar.add(jButton4);
        jToolBar.add(jButton5);
        jToolBar.add(jButton6);
        jToolBar.addSeparator();
        jToolBar.add(jButton7);
        jToolBar.add(jButton8);
        jToolBar.add(jButton9);
        jToolBar.addSeparator();
        jToolBar.addSeparator();
        jToolBar.add(jButtonA);
        // 设置工具栏不可浮动
        jToolBar.setFloatable(true);

    }

    // 制作菜单
    private void buildMenuBar() {
        // 实例菜单栏
        jMenuBar = new JMenuBar();
        jMenuBar.setBorder(BorderFactory.createTitledBorder(new LineBorder(Color.GRAY,1)));
        // 实例菜单
        jMenu1 = new JMenu("来宾登记");
        jMenu1.addSeparator();
        jMenu1.addSeparator();
        jMenu2 = new JMenu("收银结算");
        jMenu2.addSeparator();
        jMenu2.addSeparator();
        jMenu3 = new JMenu("系统维护");
        jMenu3.addSeparator();
        jMenu3.addSeparator();
        jMenu4= new JMenu("报表统计");
        jMenu4.addSeparator();
        jMenu4.addSeparator();
        jMenu5= new JMenu("草稿箱");
        jMenu5.addSeparator();
        jMenu5.addSeparator();
        jMenu6= new JMenu("回收站");
        jMenu6.addSeparator();
        jMenu6.addSeparator();

        jMenu7= new JMenu("消息中心");
        jMenu7.addSeparator();
        jMenu7.addSeparator();

        jMenu8= new JMenu("流程审批");
        jMenu8.addSeparator();
        jMenu8.addSeparator();

        jMenu9= new JMenu("监控中心");
        jMenu9.addSeparator();
        jMenu9.addSeparator();

        jMenu10= new JMenu("聊天室");
        jMenu10.addSeparator();
        jMenu10.addSeparator();


        // 实例菜单项
        jMenuItem1 = new JMenuItem("散客开单");
        jMenuItem2 = new JMenuItem("团体开单");
        jMenuItem3 = new JMenuItem("宾客续住");
        jMenuItem4 = new JMenuItem("更换房间");
        jMenuItem5 = new JMenuItem("修改登记");
        jMenuItem6 = new JMenuItem("房间状态");
        jMenuItem7 = new JMenuItem("预订管理");
        jMenuItem8 = new JMenuItem("电子提醒");
        jMenuItem9 = new JMenuItem("退出系统");

        jMenuItem21 = new JMenuItem("宾客结账");
        jMenuItem22 = new JMenuItem("合并帐单");
        jMenuItem23 = new JMenuItem("折分帐单");
        jMenuItem24 = new JMenuItem("宾客消费明细查询");
        jMenuItem25 = new JMenuItem("宾客退单明细查询");

        jMenuItem31 = new JMenuItem("网络设置");
        jMenuItem32 = new JMenuItem("系统设置");
        jMenuItem34 = new JMenuItem("数据备份");
        //未开发完毕的功能
        /*jMenuItem16.setEnabled(false);//未开发完毕的功能
        jMenuItem18.setEnabled(false);*/
        jMenuItem34.setEnabled(false);

        //组织菜单
        //来宾登记
        jMenu1.add(jMenuItem1);
        jMenu1.add(jMenuItem2);
        jMenu1.add(jMenuItem3);
        jMenu1.add(jMenuItem4);
        jMenu1.add(jMenuItem5);
        jMenu1.add(jMenuItem6);
        jMenu1.addSeparator();
        jMenu1.add(jMenuItem7);
        jMenu1.add(jMenuItem8);
        /**
         * Appends a new separator to the end of the menu.
         */
        jMenu1.addSeparator();
        jMenu1.add(jMenuItem9);
        //收银结算
        jMenu2.add(jMenuItem21);
        jMenu2.add(jMenuItem23);
        jMenu2.add(jMenuItem23);
        //系统维护
        jMenu2.add(jMenuItem31);
        jMenu2.add(jMenuItem32);
        jMenu2.addSeparator();
        jMenu2.add(jMenuItem34);
        jMenu2.addSeparator();
        //加入菜单栏
        jMenuBar.add(jMenu1);
        jMenuBar.add(jMenu2);
        jMenuBar.add(jMenu3);
        jMenuBar.add(jMenu4);
        jMenuBar.add(jMenu5);
        jMenuBar.add(jMenu6);
        jMenuBar.add(jMenu7);
        jMenuBar.add(jMenu8);
        jMenuBar.add(jMenu9);
        jMenuBar.add(jMenu10);
    }


    @Override
    public void actionPerformed(ActionEvent e) {

    }

    @Override
    public void mouseClicked(MouseEvent e) {

    }

    @Override
    public void mousePressed(MouseEvent e) {

    }

    @Override
    public void mouseReleased(MouseEvent e) {

    }

    @Override
    public void mouseEntered(MouseEvent e) {

    }

    @Override
    public void mouseExited(MouseEvent e) {

    }

    @Override
    public void run() {

    }





    public static void main(String sd[]) {
        SSOSumMetalTool.setWindowStyle(SSOSystemIni.getIniKey("Sys_style").charAt(0));
        HotelMainFrame hotelMainFrame = new HotelMainFrame("杨洋哥", "管理员");
        // 设置窗体透明度
        AWTUtilities.setWindowOpacity(hotelMainFrame, 0.95f);
        // 设置窗体透明
        //AWTUtilities.setWindowOpacity(hotelMainFrame, 0.51f);
    }

}


                                           

                                               -------------特效雨滴--------------------

package org.jd.data.netty.big.window.chat.frame.ui.room.main;

import org.jd.data.netty.big.window.chat.frame.ui.controller.center.SSOControllerCenterManager;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.Point2D;

/**
 * 左侧底部面板
 */
public class HotelMainLeftBottomPanel extends JPanel implements ActionListener, MouseListener, FocusListener ,Runnable{

    private SSOControllerCenterManager ssoControllerCenterManager = SSOControllerCenterManager.newInstance();
    // 控制雨滴密度啊
    private volatile Point2D.Double[] pts = new Point2D.Double[2000];
    public HotelMainLeftBottomPanel(){
        this.setBackground(Color.WHITE);
        this.setOpaque(false); //把panel的背景色设为透明
        for (int i = 0; i < pts.length; i++) {
            pts[i] = new Point2D.Double(Math.random(), Math.random());
        }
        ssoControllerCenterManager.getExecutorService().submit(this);
    }



    @Override
    public void actionPerformed(ActionEvent e) {

    }

    @Override
    public void focusGained(FocusEvent e) {

    }

    @Override
    public void focusLost(FocusEvent e) {

    }

    @Override
    public void mouseClicked(MouseEvent e) {

    }

    @Override
    public void mousePressed(MouseEvent e) {

    }

    @Override
    public void mouseReleased(MouseEvent e) {

    }

    @Override
    public void mouseEntered(MouseEvent e) {

    }

    @Override
    public void mouseExited(MouseEvent e) {

    }
    @Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D graphics2D = (Graphics2D) g;
        // 控制雨滴颜色
        // 随机的颜色,不超过255,在for循环中绘制
        for (int i = 0; i < pts.length; i++) {
            graphics2D.setColor(new Color((int) (250 * Math.random()), (int) (255 * Math.random()), (int) (25 * Math.random())));
            int x = (int) (2340 * pts[i].x);
            int y = (int) (1480 * pts[i].y);
            // 控制雨点的长度
            int h = (int) (100 * Math.random());
            //System.out.println("随机数:"+255*Math.random());
            // 条件不同的参数会得到不同的效果
            //graphics2D.drawLine(x, y, (x+y-500), y+h);
            graphics2D.drawLine(x, y, x, y + h); // 竖直向下
            //graphics2D.setColor(Color.BLACK);
            //graphics2D.setFont(new Font("宋体",Font.BOLD,14));
            //graphics2D.drawString("天空飘来两个字,那都不是事",x, y-250);
        }
    }

    @Override
    public void run() {
        while (true) {
            for (int i = 0; i < pts.length; i++) {
                double x = pts[i].getX();
                double y = pts[i].getY();
                y += 0.1 * Math.random();
                if (y > 1) {
                    y = 0.3 * Math.random();
                    x = Math.random();
                }
                pts[i].setLocation(x, y);
            }
            this.repaint();
            try {
                Thread.sleep(100);
            } catch (InterruptedException ex) {
                ex.printStackTrace();
            }
        }
    }
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值