Browse Source

初始化

chenanlian 5 months ago
parent
commit
8c817af359

+ 46 - 6
src/main/java/com/wefanbot/winbot/Frame.java

@@ -5,10 +5,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.swing.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
+import java.awt.*;
+import java.awt.event.*;
 import java.io.File;
 
 public class Frame extends JFrame {
@@ -41,21 +39,63 @@ public class Frame extends JFrame {
     public static File excelSource;
     public static File imgDir;
 
-    public Frame(int width, int height, int panelOperatorWidth) {
+    /**
+     * 操作面板的宽度
+     */
+    private int panelOperatorWidth;
+    private Panel panel;
+    /**
+     * 操作面板
+     */
+    private PanelOperator panelOperator;
 
+    public Panel getPanel() {
+        return panel;
+    }
+
+    public PanelOperator getPanelOperator() {
+        return panelOperator;
+    }
+
+    public Frame(int width, int height, int panelOperatorWidth) {
+        this.panelOperatorWidth = panelOperatorWidth;
         this.WIDTH = width;
         this.HEIGHT = height;
 
-        this.setTitle("EXCEL");
+        this.setTitle("Winbot");
         this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         this.setSize(width, height);
         this.setResizable(false);
         this.setLayout(null);
         setLocationRelativeTo(null);
         this.initMenuBar();
+        this.initPanel(width, height);
     }
 
     /**
+     * 初始化面板
+     * @param width
+     * @param height
+     */
+    private void initPanel(int width, int height) {
+        int panelWidth = width - panelOperatorWidth;
+        int panelHeight = height - menuBarHeight;
+
+
+
+        panel = new Panel();
+        panel.setBounds(0, 0, panelWidth, panelHeight);
+
+        panelOperator = new PanelOperator(panelWidth, 0, panelOperatorWidth, panelHeight, this);
+
+        this.add(panelOperator);
+        this.add(panel);
+
+        this.setVisible(true);
+
+
+    }
+    /**
      * 初始化菜单
      */
     private void initMenuBar() {

+ 1 - 1
src/main/java/com/wefanbot/winbot/Main.java

@@ -36,7 +36,7 @@ public class Main {
             CountDownLatch countDownLatchFrame = new CountDownLatch(1);
             javax.swing.SwingUtilities.invokeLater(new Runnable() {
                 public void run() {
-                    f = new Frame(300, 100, 0);
+                    f = new Frame(500, 500, 0);
                     countDownLatchFrame.countDown();
                 }
             });

+ 17 - 0
src/main/java/com/wefanbot/winbot/Panel.java

@@ -0,0 +1,17 @@
+package com.wefanbot.winbot;
+
+import javax.swing.*;
+
+/**
+ * 绘图面板
+ */
+public class Panel extends JPanel {
+
+
+    public Panel() {
+
+        this.setFocusable(true);
+    }
+
+
+}

+ 25 - 0
src/main/java/com/wefanbot/winbot/PanelOperator.java

@@ -0,0 +1,25 @@
+package com.wefanbot.winbot;
+
+
+import javax.swing.*;
+
+public class PanelOperator extends JPanel {
+
+    Frame frame;
+
+    public PanelOperator(int x, int y, int width, int height, Frame frame) {
+        this.frame = frame;
+        this.setLayout(null);
+        this.setLocation(x, 0);
+        this.setSize(width, height);
+
+        init(frame.getPanel());
+    }
+
+
+    private void init(Panel panel) {
+
+
+    }
+
+}