|
|
@@ -38,9 +38,45 @@ import java.util.Timer;
|
|
|
import java.util.TimerTask;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
+import java.util.IdentityHashMap;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
public class MesClient extends JFrame {
|
|
|
|
|
|
+ private static class CenteredPanel extends JPanel {
|
|
|
+ private final int contentWidth;
|
|
|
+ private final int contentHeight;
|
|
|
+ private final Map<Component, Rectangle> designBounds = new IdentityHashMap<>();
|
|
|
+
|
|
|
+ CenteredPanel(int contentWidth, int contentHeight) {
|
|
|
+ this.contentWidth = contentWidth;
|
|
|
+ this.contentHeight = contentHeight;
|
|
|
+ setLayout(null);
|
|
|
+ setPreferredSize(new Dimension(contentWidth, contentHeight));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void doLayout() {
|
|
|
+ double scale = Math.min((double) getWidth() / contentWidth,
|
|
|
+ (double) getHeight() / contentHeight);
|
|
|
+ int width = (int) Math.round(contentWidth * scale);
|
|
|
+ int height = (int) Math.round(contentHeight * scale);
|
|
|
+ int x = (getWidth() - width) / 2;
|
|
|
+ int y = (getHeight() - height) / 2;
|
|
|
+ for (Component component : getComponents()) {
|
|
|
+ Rectangle bounds = designBounds.get(component);
|
|
|
+ if (bounds == null) {
|
|
|
+ bounds = component.getBounds();
|
|
|
+ designBounds.put(component, new Rectangle(bounds));
|
|
|
+ }
|
|
|
+ component.setBounds(x + (int) Math.round(bounds.x * scale),
|
|
|
+ y + (int) Math.round(bounds.y * scale),
|
|
|
+ (int) Math.round(bounds.width * scale),
|
|
|
+ (int) Math.round(bounds.height * scale));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private static String Drivde = "org.sqlite.JDBC";
|
|
|
|
|
|
public static int mes_auth = 0; // 权限级别 0=无权限 1=操作工人 2=管理员
|
|
|
@@ -745,7 +781,7 @@ public class MesClient extends JFrame {
|
|
|
contentPane.add(tabbedPane);
|
|
|
|
|
|
//首页
|
|
|
- JPanel indexPanelA = new JPanel();
|
|
|
+ JPanel indexPanelA = new CenteredPanel(972, 450);
|
|
|
indexScrollPaneA = new JScrollPane(indexPanelA);
|
|
|
indexPanelA.setLayout(null);
|
|
|
|
|
|
@@ -1029,35 +1065,37 @@ public class MesClient extends JFrame {
|
|
|
tabbedPane.addTab("工作面板", new ImageIcon(MesClient.class.getResource("/bg/a_side.png")), indexScrollPaneA, null);
|
|
|
tabbedPane.setEnabledAt(0, true);
|
|
|
|
|
|
- JPanel unbindPanel = new JPanel();
|
|
|
- JScrollPane unbindScrollPane = new JScrollPane(unbindPanel);
|
|
|
- unbindPanel.setLayout(null);
|
|
|
+ JPanel unbindPanel = new CenteredPanel(810, 370);
|
|
|
+ JPanel unbindContainer = new JPanel(new GridBagLayout());
|
|
|
+ unbindContainer.add(unbindPanel);
|
|
|
+ JScrollPane unbindScrollPane = new JScrollPane(unbindContainer);
|
|
|
+ unbindScrollPane.getVerticalScrollBar().setUnitIncrement(16);
|
|
|
|
|
|
JLabel unbindTitle = new JLabel("钢印码解绑");
|
|
|
unbindTitle.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
unbindTitle.setForeground(Color.BLACK);
|
|
|
unbindTitle.setFont(new Font("微软雅黑", Font.PLAIN, 28));
|
|
|
- unbindTitle.setBounds(260, 80, 420, 50);
|
|
|
+ unbindTitle.setBounds(195, 80, 420, 50);
|
|
|
unbindPanel.add(unbindTitle);
|
|
|
|
|
|
JLabel unbindInputLabel = new JLabel("钢印码");
|
|
|
unbindInputLabel.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
unbindInputLabel.setForeground(Color.BLACK);
|
|
|
unbindInputLabel.setFont(new Font("微软雅黑", Font.PLAIN, 22));
|
|
|
- unbindInputLabel.setBounds(170, 170, 120, 50);
|
|
|
+ unbindInputLabel.setBounds(160, 170, 120, 50);
|
|
|
unbindPanel.add(unbindInputLabel);
|
|
|
|
|
|
final JTextField unbindSteelSnInput = new JTextField();
|
|
|
unbindSteelSnInput.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
unbindSteelSnInput.setFont(new Font("微软雅黑", Font.PLAIN, 24));
|
|
|
unbindSteelSnInput.setToolTipText("输入11位钢印码");
|
|
|
- unbindSteelSnInput.setBounds(320, 170, 340, 50);
|
|
|
+ unbindSteelSnInput.setBounds(310, 170, 340, 50);
|
|
|
unbindPanel.add(unbindSteelSnInput);
|
|
|
|
|
|
final JButton unbindSteelSnBt = new JButton("解绑钢印码");
|
|
|
unbindSteelSnBt.setEnabled(false);
|
|
|
unbindSteelSnBt.setFont(new Font("微软雅黑", Font.PLAIN, 24));
|
|
|
- unbindSteelSnBt.setBounds(320, 250, 220, 60);
|
|
|
+ unbindSteelSnBt.setBounds(295, 250, 220, 60);
|
|
|
unbindSteelSnBt.addActionListener(new ActionListener() {
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
requestUnbindSteelSn(unbindSteelSnInput.getText(), unbindSteelSnInput);
|
|
|
@@ -1089,22 +1127,19 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
// searchScrollPane = new JScrollPane((Component) null);
|
|
|
|
|
|
- indexPanelC = new JPanel();
|
|
|
+ indexPanelC = new JPanel(new BorderLayout());
|
|
|
searchScrollPaneDj = new JScrollPane(indexPanelC);
|
|
|
- indexPanelC.setLayout(null);
|
|
|
|
|
|
tabbedPane.addTab("开班点检", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), searchScrollPaneDj, null);
|
|
|
|
|
|
|
|
|
- indexPanelB = new JPanel();
|
|
|
+ indexPanelB = new JPanel(new BorderLayout());
|
|
|
searchScrollPane = new JScrollPane(indexPanelB);
|
|
|
- indexPanelB.setLayout(null);
|
|
|
|
|
|
tabbedPane.addTab("工作记录", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), searchScrollPane, null);
|
|
|
|
|
|
- indexPanelD = new JPanel();
|
|
|
+ indexPanelD = new JPanel(new BorderLayout());
|
|
|
JScrollPane relationScrollPane = new JScrollPane(indexPanelD);
|
|
|
- indexPanelD.setLayout(null);
|
|
|
|
|
|
tabbedPane.addTab("绑定关系", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), relationScrollPane, null);
|
|
|
|
|
|
@@ -1182,6 +1217,8 @@ public class MesClient extends JFrame {
|
|
|
// 确保窗口布局正确
|
|
|
pack();
|
|
|
setSize(1024, 768);
|
|
|
+ setMaximizedBounds(GraphicsEnvironment.getLocalGraphicsEnvironment()
|
|
|
+ .getMaximumWindowBounds());
|
|
|
validate();
|
|
|
repaint();
|
|
|
}
|