| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Locale; |
| | | import denglu.Denglu; |
| | | import denglu.UserChuShiHua; |
| | | |
| | | /** |
| | | * 设置对话框 - 参考Shouye.java样式 |
| | |
| | | JPanel manualBoundaryDrawingPanel = createManualBoundaryDrawingPanel(); |
| | | manualBoundaryDrawingModeLabel = (JLabel) manualBoundaryDrawingPanel.getClientProperty("valueLabel"); |
| | | |
| | | // 修改密码设置项 |
| | | JPanel changePasswordPanel = createChangePasswordPanel(); |
| | | |
| | | JPanel feedbackPanel = createFeedbackPanel(); |
| | | |
| | | // APP版本 |
| | | JPanel appVersionPanel = createAppVersionPanel(); |
| | | |
| | | // 退出登录 |
| | | JPanel logoutPanel = createLogoutPanel(); |
| | | |
| | | // 添加设置项,使用分割线分隔 |
| | | addSettingItem(panel, mowerIdPanel, true); |
| | | addSettingItem(panel, mowerSizePanel, true); |
| | |
| | | addSettingItem(panel, boundaryLengthPanel, true); |
| | | addSettingItem(panel, measurementModePanel, true); |
| | | addSettingItem(panel, manualBoundaryDrawingPanel, true); |
| | | addSettingItem(panel, changePasswordPanel, true); |
| | | addSettingItem(panel, feedbackPanel, true); |
| | | addSettingItem(panel, appVersionPanel, false); // 最后一项不加分割线 |
| | | addSettingItem(panel, appVersionPanel, true); |
| | | addSettingItem(panel, logoutPanel, false); // 最后一项不加分割线 |
| | | |
| | | container.add(panel, BorderLayout.CENTER); |
| | | return container; |
| | |
| | | } |
| | | super.setVisible(visible); |
| | | } |
| | | |
| | | |
| | | private JPanel createLogoutPanel() { |
| | | JPanel panel = new JPanel(new GridBagLayout()); |
| | | panel.setOpaque(false); |
| | | panel.setAlignmentX(Component.LEFT_ALIGNMENT); |
| | | panel.setMaximumSize(new Dimension(Integer.MAX_VALUE, ROW_HEIGHT + 20)); |
| | | panel.setBorder(BorderFactory.createEmptyBorder(ITEM_PADDING, ITEM_PADDING, ITEM_PADDING, ITEM_PADDING)); |
| | | |
| | | JButton logoutBtn = new JButton("退出登录"); |
| | | logoutBtn.setFont(new Font("微软雅黑", Font.BOLD, 14)); |
| | | logoutBtn.setForeground(Color.WHITE); |
| | | logoutBtn.setBackground(new Color(220, 53, 69)); // Red color |
| | | logoutBtn.setFocusPainted(false); |
| | | logoutBtn.setBorderPainted(false); |
| | | logoutBtn.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
| | | logoutBtn.setPreferredSize(new Dimension(200, 40)); |
| | | |
| | | logoutBtn.addActionListener(e -> { |
| | | int confirm = JOptionPane.showConfirmDialog(this, |
| | | "确定要退出登录吗?", "退出确认", |
| | | JOptionPane.YES_NO_OPTION); |
| | | |
| | | if (confirm == JOptionPane.YES_OPTION) { |
| | | // Reset Remember Me |
| | | UserChuShiHua.updateProperty("rememberPassword", "0"); |
| | | |
| | | // Close current dialog |
| | | dispose(); |
| | | |
| | | // Close all windows and open Login |
| | | for (Window window : Window.getWindows()) { |
| | | if (window.isDisplayable()) { |
| | | window.dispose(); |
| | | } |
| | | } |
| | | |
| | | SwingUtilities.invokeLater(() -> { |
| | | new Denglu().setVisible(true); |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | | gbc.gridx = 0; |
| | | gbc.gridy = 0; |
| | | gbc.weightx = 1.0; |
| | | gbc.anchor = GridBagConstraints.CENTER; |
| | | panel.add(logoutBtn, gbc); |
| | | |
| | | return panel; |
| | | } |
| | | |
| | | /** |
| | | * 创建修改密码设置面板 |
| | | */ |
| | | private JPanel createChangePasswordPanel() { |
| | | JPanel panel = new JPanel(new GridBagLayout()); |
| | | panel.setOpaque(false); |
| | | panel.setAlignmentX(Component.LEFT_ALIGNMENT); |
| | | panel.setMaximumSize(new Dimension(Integer.MAX_VALUE, ROW_HEIGHT)); |
| | | panel.setPreferredSize(new Dimension(Integer.MAX_VALUE, ROW_HEIGHT)); |
| | | panel.setMinimumSize(new Dimension(0, ROW_HEIGHT)); |
| | | panel.setBorder(BorderFactory.createEmptyBorder(ITEM_PADDING, ITEM_PADDING, ITEM_PADDING, ITEM_PADDING)); |
| | | |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | | |
| | | JLabel titleLabel = new JLabel("修改密码"); |
| | | titleLabel.setFont(new Font("微软雅黑", Font.BOLD, 14)); |
| | | titleLabel.setForeground(Color.BLACK); |
| | | titleLabel.setHorizontalAlignment(SwingConstants.RIGHT); |
| | | gbc.gridx = 0; |
| | | gbc.gridy = 0; |
| | | gbc.weightx = 0; |
| | | gbc.anchor = GridBagConstraints.EAST; |
| | | gbc.insets = new Insets(0, 0, 0, 12); |
| | | panel.add(titleLabel, gbc); |
| | | |
| | | JLabel valueLabel = new JLabel("******"); |
| | | valueLabel.setFont(new Font("微软雅黑", Font.PLAIN, 14)); |
| | | valueLabel.setForeground(Color.DARK_GRAY); |
| | | gbc = new GridBagConstraints(); |
| | | gbc.gridx = 1; |
| | | gbc.gridy = 0; |
| | | gbc.weightx = 1.0; |
| | | gbc.anchor = GridBagConstraints.EAST; |
| | | panel.add(valueLabel, gbc); |
| | | |
| | | JButton editBtn = createEditButton(); |
| | | editBtn.addActionListener(e -> { |
| | | SwingUtilities.invokeLater(() -> { |
| | | xiugaimima dialog = new xiugaimima((Frame) SwingUtilities.getWindowAncestor(this)); |
| | | dialog.setVisible(true); |
| | | }); |
| | | }); |
| | | |
| | | gbc = new GridBagConstraints(); |
| | | gbc.gridx = 2; |
| | | gbc.gridy = 0; |
| | | gbc.weightx = 0; |
| | | gbc.anchor = GridBagConstraints.EAST; |
| | | panel.add(editBtn, gbc); |
| | | |
| | | return panel; |
| | | } |
| | | } |