修改一些问题

This commit is contained in:
wenli 2024-07-29 09:16:03 +08:00
parent 024cb688ae
commit 25f47615f0
2 changed files with 43 additions and 36 deletions

View File

@ -60,6 +60,7 @@ public class MainFrame extends JFrame {
private JButton refreshBut; private JButton refreshBut;
private JButton noticeBut; private JButton noticeBut;
private JPopupMenu themePopupMenu; private JPopupMenu themePopupMenu;
private JPopupMenu personalPopupMenu;
private MainFrame() { private MainFrame() {
MainPrefs.init(PREFS_ROOT_PATH); MainPrefs.init(PREFS_ROOT_PATH);
@ -289,6 +290,9 @@ public class MainFrame extends JFrame {
if (themePopupMenu != null) { if (themePopupMenu != null) {
SwingUtilities.updateComponentTreeUI(themePopupMenu); SwingUtilities.updateComponentTreeUI(themePopupMenu);
} }
if (personalPopupMenu != null) {
SwingUtilities.updateComponentTreeUI(personalPopupMenu);
}
} }
}; };
// left // left
@ -504,45 +508,48 @@ public class MainFrame extends JFrame {
* 显示弹出菜单按钮执行操作 * 显示弹出菜单按钮执行操作
*/ */
private void showPopupMenuButtonActionPerformed(Component invoker) { private void showPopupMenuButtonActionPerformed(Component invoker) {
JPopupMenu popupMenu = new JPopupMenu(); if (personalPopupMenu == null) {
personalPopupMenu = new JPopupMenu();
JPanel infoPanel = new JPanel(new BorderLayout());
JLabel label = new JLabel("", JLabel.CENTER);
label.setIcon(new FlatSVGIcon("icons/user.svg", 80, 80));
label.setText("admin");
label.setVerticalTextPosition(SwingConstants.BOTTOM); //必须设置文字树直方向位置
label.setHorizontalTextPosition(SwingConstants.CENTER);
infoPanel.add(label, BorderLayout.CENTER);
infoPanel.add(new JLabel("系统管理员", JLabel.CENTER), BorderLayout.SOUTH);
label.setPreferredSize(new Dimension(240, 100));
JMenuItem menuItem9 = new JMenuItem("个人信息");
menuItem9.setIcon(new FlatSVGIcon("icons/gerenxinxi.svg", 25, 25));
JMenuItem menuItem11 = new JMenuItem("退出");
menuItem11.setIcon(new FlatSVGIcon("icons/logout.svg", 25, 25));
JPanel infoPanel = new JPanel(new BorderLayout()); menuItem11.addActionListener(e1 -> loginOut(false));
JLabel label = new JLabel("", JLabel.CENTER); menuItem9.addActionListener(e1 -> {
label.setIcon(new FlatSVGIcon("icons/user.svg", 80, 80));
label.setText("admin");
label.setVerticalTextPosition(SwingConstants.BOTTOM); //必须设置文字树直方向位置
label.setHorizontalTextPosition(SwingConstants.CENTER);
infoPanel.add(label, BorderLayout.CENTER);
infoPanel.add(new JLabel("系统管理员", JLabel.CENTER), BorderLayout.SOUTH);
label.setPreferredSize(new Dimension(240, 100));
JMenuItem menuItem9 = new JMenuItem("个人信息");
menuItem9.setIcon(new FlatSVGIcon("icons/gerenxinxi.svg", 25, 25));
JMenuItem menuItem11 = new JMenuItem("退出");
menuItem11.setIcon(new FlatSVGIcon("icons/logout.svg", 25, 25));
menuItem11.addActionListener(e1 -> loginOut(false)); int tabIndex = MainFrame.getInstance().getTabbedPane().indexOfTab("个人信息");
menuItem9.addActionListener(e1 -> { PersonalCenterPanel personalCenterPanel;
if (tabIndex == -1) {
int tabIndex = MainFrame.getInstance().getTabbedPane().indexOfTab("个人信息"); personalCenterPanel = new PersonalCenterPanel();
PersonalCenterPanel personalCenterPanel; MainFrame.getInstance().getTabbedPane().addTab("个人信息", personalCenterPanel);
if (tabIndex == -1) { } else {
personalCenterPanel = new PersonalCenterPanel(); personalCenterPanel = (PersonalCenterPanel) MainFrame.getInstance().getTabbedPane().getComponentAt(tabIndex);
MainFrame.getInstance().getTabbedPane().addTab("个人信息", personalCenterPanel); }
} else { MainFrame.getInstance().getTabbedPane().setSelectedIndex(MainFrame.getInstance().getTabbedPane().indexOfTab("个人信息"));
personalCenterPanel = (PersonalCenterPanel) MainFrame.getInstance().getTabbedPane().getComponentAt(tabIndex); personalCenterPanel.updateData();
}
MainFrame.getInstance().getTabbedPane().setSelectedIndex(MainFrame.getInstance().getTabbedPane().indexOfTab("个人信息"));
personalCenterPanel.updateData();
}); });
popupMenu.add(infoPanel); personalPopupMenu.add(infoPanel);
popupMenu.addSeparator(); personalPopupMenu.addSeparator();
popupMenu.add(menuItem9); personalPopupMenu.add(menuItem9);
popupMenu.addSeparator(); personalPopupMenu.addSeparator();
popupMenu.add(menuItem11); personalPopupMenu.add(menuItem11);
popupMenu.show(invoker, 0, invoker.getHeight()); }
personalPopupMenu.show(invoker, 0, invoker.getHeight());
} }

View File

@ -167,7 +167,7 @@ public class MyNotifyMessagePane extends JPanel {
startDateTextField.setValue(null); startDateTextField.setValue(null);
endDateTextField.setValue(null); endDateTextField.setValue(null);
table.setDefaultRenderer(Object.class, new CenterTableCellRenderer()); table.setDefaultRenderer(Object.class, new CenterTableCellRenderer());
setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
} }
@Override @Override
@ -270,7 +270,7 @@ public class MyNotifyMessagePane extends JPanel {
for (int i = 0; i < tableModel.getRowCount(); i++) { for (int i = 0; i < tableModel.getRowCount(); i++) {
Boolean b = (Boolean) tableModel.getValueAt(i, 0); Boolean b = (Boolean) tableModel.getValueAt(i, 0);
if (b) { if (b) {
NotifyMessageRespVO notifyMessageRespVO = (NotifyMessageRespVO) tableModel.getValueAt(i, COLUMN_ID.length-1); NotifyMessageRespVO notifyMessageRespVO = (NotifyMessageRespVO) tableModel.getValueAt(i, COLUMN_ID.length - 1);
ids.add(notifyMessageRespVO.getId()); ids.add(notifyMessageRespVO.getId());
} }