|
|
@@ -35,6 +35,34 @@ import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
|
public class MesClient extends JFrame {
|
|
|
+
|
|
|
+ /** Keeps the fixed-size operator controls centered when the workstation uses a large display. */
|
|
|
+ private static class CenteredPanel extends JPanel {
|
|
|
+ private final int contentWidth;
|
|
|
+ private final int contentHeight;
|
|
|
+
|
|
|
+ CenteredPanel(int contentWidth, int contentHeight) {
|
|
|
+ this.contentWidth = contentWidth;
|
|
|
+ this.contentHeight = contentHeight;
|
|
|
+ setLayout(null);
|
|
|
+ setPreferredSize(new Dimension(contentWidth, contentHeight));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void doLayout() {
|
|
|
+ int x = Math.max(0, (getWidth() - contentWidth) / 2);
|
|
|
+ int y = Math.max(0, (getHeight() - contentHeight) / 2);
|
|
|
+ for (Component child : getComponents()) {
|
|
|
+ JComponent component = (JComponent) child;
|
|
|
+ Rectangle bounds = (Rectangle) component.getClientProperty("designBounds");
|
|
|
+ if (bounds == null) {
|
|
|
+ bounds = child.getBounds();
|
|
|
+ component.putClientProperty("designBounds", new Rectangle(bounds));
|
|
|
+ }
|
|
|
+ child.setLocation(bounds.x + x, bounds.y + y);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
public static final Logger log = LoggerFactory.getLogger(MesClient.class);
|
|
|
|
|
|
public static int mes_auth = 0; // 权限级别 0=无权限 1=操作工人 2=管理员
|
|
|
@@ -386,10 +414,6 @@ public class MesClient extends JFrame {
|
|
|
setTitle("MES系统客户端:"+mes_gw + "- " + mes_gw_des);
|
|
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
// Maximize within the desktop work area so the system taskbar remains visible.
|
|
|
- setMaximizedBounds(GraphicsEnvironment.getLocalGraphicsEnvironment()
|
|
|
- .getMaximumWindowBounds());
|
|
|
- setExtendedState(JFrame.MAXIMIZED_BOTH);
|
|
|
- validate();
|
|
|
|
|
|
JMenuBar menuBar = new JMenuBar();
|
|
|
menuBar.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 26));
|
|
|
@@ -533,7 +557,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);
|
|
|
|
|
|
@@ -642,22 +666,22 @@ 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);
|
|
|
|
|
|
// 确保窗口布局正确
|
|
|
pack();
|
|
|
setSize(1024, 768);
|
|
|
+ setMaximizedBounds(GraphicsEnvironment.getLocalGraphicsEnvironment()
|
|
|
+ .getMaximumWindowBounds());
|
|
|
validate();
|
|
|
repaint();
|
|
|
|