------------------界面截图---------------------
单例: package org.jd.data.netty.big.window.chat.frame.ui.controller.center; import java.util.Objects; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; /** * 保证该类不被继承,就不会被拓展,从而不会修改该数据代码 * 重写线程池中线程工厂,注入各任务名称,便于排查问题 */ public final class SSOCustomerExecutorServiceFactory { // 对线程安全天生免疫: 没修改的入口,只有获取的方法 private static volatile ExecutorService executorService = null; private SSOCustomerExecutorServiceFactory(){ System.out.println("会被创建多少次SSOCustomerExecutorServiceFactory"); } public synchronized static ExecutorService newInstance() { if (Objects.isNull(executorService)) { executorService = Executors.newWorkStealingPool(); System.out.println("线程池会被创建多次吗: "); } return executorService; } }
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(); } } } }