public class Main extends JFrame { // private final String menuBarXML = "conf/menubar.xml"; private final String outlookPanelXML = "conf/outlook.xml"; private ContainerPanel container; // ?????? public MyStatusBar statusBar; // ???????? private MyMenuBar menubar; // private TabPanel tabPanel; private OutlookPanel outlookPanel; static Point lastPoint = null; private String username; public Main(String username) { // 构造函数 this.username = username; //第一步设置username的值 container = new ContainerPanel(); // 初始化外部窗口容器 container.setBorder(BorderFactory.createMatteBorder(1, 2, 2, 2, new Color(55,155,11))); //边框 setContentPane(container); setTitle("Checount DV2.0"); setDefaultCloseOperation(3); setSize(780, 500); setUndecorated(true); // 设置窗口无边缘 setLocationRelativeTo(null); //正中显示 addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { lastPoint = e.getLocationOnScreen(); } }); addMouseMotionListener(new MouseMotionListener() { @Override public void mouseDragged(MouseEvent e) { Point point = e.getLocationOnScreen(); // 这个是持续移动的点 int offsetX = point.x - lastPoint.x; int offsetY = point.y - lastPoint.y; Rectangle bounds = Main.this.getBounds(); Main.this.setLocation(bounds.x + offsetX, bounds.y + offsetY); lastPoint = point; } @Override public void mouseMoved(MouseEvent e) { } }); setIconImage(UUtils.getImage("ui/images/logo.png")); // 设置标题栏图标 initMenubar(); // 初始化菜单栏 initTab(); // 初始化标签栏 initOutlookPanel(); // 初始化左侧导航栏 initStatusbar(); // 初始化状态栏 } private void initMenubar() { // 初始化菜单栏 menubar = UUtils.loadMenuBar(menuBarXML, new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getActionCommand().contains("tab")) { String commands = e.getActionCommand(); if (commands.equals("tab_today")) { if (-1 == tabPanel.indexOfTab("今日")) //不存在则新添 tabPanel.addTab("今日", UUtils.getImageIcon("ui/images/submodule.png"), createTrapPage(new JPanel())); tabPanel.setSelectedIndex(tabPanel.indexOfTab("今日")); }else if (commands.equals("tab_history")) { if (-1 == tabPanel.indexOfTab("历史")) tabPanel.addTab("历史", UUtils.getImageIcon("ui/images/submodule.png"),createHistoryPage()); tabPanel.setSelectedIndex(tabPanel.indexOfTab("历史")); }else if (commands.equals("tab_statistic")) { if (-1 == tabPanel.indexOfTab("统计")) tabPanel.addTab("统计", UUtils.getImageIcon("ui/images/submodule.png"), createStatisticPage(new JPanel())); tabPanel.setSelectedIndex(tabPanel.indexOfTab("统计")); }else if(commands.equals("tab_browser")){ if (-1 == tabPanel.indexOfTab("浏览网络")) tabPanel.addTab("浏览网络", UUtils.getImageIcon("ui/images/submodule.png"), createPage(new JPanel())); tabPanel.setSelectedIndex(tabPanel.indexOfTab("浏览网络")); } } else MenubarAction.executeByCommand(e.getActionCommand()); // 其余的转至Acton中执行 } }); container.add(menubar, "North"); }