去除菜单栏,仅保留工具栏
This commit is contained in:
@@ -35,10 +35,7 @@ public class ImageDotMarker extends JFrame {
|
|||||||
// 设置窗口在屏幕中心显示
|
// 设置窗口在屏幕中心显示
|
||||||
setLocationRelativeTo(null);
|
setLocationRelativeTo(null);
|
||||||
|
|
||||||
// 创建菜单栏
|
// 只保留工具栏
|
||||||
createMenuBar();
|
|
||||||
|
|
||||||
// 创建工具栏
|
|
||||||
createToolbar();
|
createToolbar();
|
||||||
|
|
||||||
// 创建主面板
|
// 创建主面板
|
||||||
@@ -48,36 +45,7 @@ public class ImageDotMarker extends JFrame {
|
|||||||
createStatusBar();
|
createStatusBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createMenuBar() {
|
|
||||||
JMenuBar menuBar = new JMenuBar();
|
|
||||||
JMenu fileMenu = new JMenu("文件");
|
|
||||||
JMenuItem openItem = new JMenuItem("打开图片");
|
|
||||||
JMenuItem saveItem = new JMenuItem("保存图片");
|
|
||||||
JMenuItem exitItem = new JMenuItem("退出");
|
|
||||||
|
|
||||||
openItem.addActionListener(e -> openImage());
|
|
||||||
saveItem.addActionListener(e -> saveImage());
|
|
||||||
exitItem.addActionListener(e -> System.exit(0));
|
|
||||||
|
|
||||||
fileMenu.add(openItem);
|
|
||||||
fileMenu.add(saveItem);
|
|
||||||
fileMenu.addSeparator();
|
|
||||||
fileMenu.add(exitItem);
|
|
||||||
menuBar.add(fileMenu);
|
|
||||||
|
|
||||||
JMenu pointMenu = new JMenu("标记点");
|
|
||||||
JMenuItem clearItem = new JMenuItem("清除所有标记");
|
|
||||||
JMenuItem exportTextItem = new JMenuItem("导出坐标(文本)");
|
|
||||||
|
|
||||||
clearItem.addActionListener(e -> clearPoints());
|
|
||||||
exportTextItem.addActionListener(e -> exportPointsAsText());
|
|
||||||
|
|
||||||
pointMenu.add(clearItem);
|
|
||||||
pointMenu.add(exportTextItem);
|
|
||||||
menuBar.add(pointMenu);
|
|
||||||
|
|
||||||
setJMenuBar(menuBar);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createToolbar() {
|
private void createToolbar() {
|
||||||
JToolBar toolBar = new JToolBar();
|
JToolBar toolBar = new JToolBar();
|
||||||
@@ -96,9 +64,18 @@ public class ImageDotMarker extends JFrame {
|
|||||||
clearBtn.addActionListener(e -> clearPoints());
|
clearBtn.addActionListener(e -> clearPoints());
|
||||||
|
|
||||||
JButton exportTextBtn = new JButton("导出文本");
|
JButton exportTextBtn = new JButton("导出文本");
|
||||||
exportTextBtn.setToolTipText("导出坐标为文本");
|
exportTextBtn.setToolTipText("导出坐标为CSV文件");
|
||||||
exportTextBtn.addActionListener(e -> exportPointsAsText());
|
exportTextBtn.addActionListener(e -> exportPointsAsText());
|
||||||
|
|
||||||
|
toolBar.add(openBtn);
|
||||||
|
toolBar.add(saveBtn);
|
||||||
|
toolBar.addSeparator();
|
||||||
|
toolBar.add(clearBtn);
|
||||||
|
toolBar.add(exportTextBtn);
|
||||||
|
|
||||||
|
// 添加分隔符
|
||||||
|
toolBar.addSeparator();
|
||||||
|
|
||||||
// 缩放控件
|
// 缩放控件
|
||||||
JButton zoomInBtn = new JButton("放大");
|
JButton zoomInBtn = new JButton("放大");
|
||||||
zoomInBtn.addActionListener(e -> zoomImage(1.25));
|
zoomInBtn.addActionListener(e -> zoomImage(1.25));
|
||||||
@@ -109,15 +86,30 @@ public class ImageDotMarker extends JFrame {
|
|||||||
JButton resetZoomBtn = new JButton("重置");
|
JButton resetZoomBtn = new JButton("重置");
|
||||||
resetZoomBtn.addActionListener(e -> resetZoom());
|
resetZoomBtn.addActionListener(e -> resetZoom());
|
||||||
|
|
||||||
toolBar.add(openBtn);
|
|
||||||
toolBar.add(saveBtn);
|
|
||||||
toolBar.addSeparator();
|
|
||||||
toolBar.add(clearBtn);
|
|
||||||
toolBar.add(exportTextBtn);
|
|
||||||
toolBar.addSeparator();
|
|
||||||
toolBar.add(zoomInBtn);
|
toolBar.add(zoomInBtn);
|
||||||
toolBar.add(zoomOutBtn);
|
toolBar.add(zoomOutBtn);
|
||||||
toolBar.add(resetZoomBtn);
|
toolBar.add(resetZoomBtn);
|
||||||
|
|
||||||
|
// 添加分隔符
|
||||||
|
toolBar.addSeparator();
|
||||||
|
|
||||||
|
// 添加帮助和退出按钮
|
||||||
|
JButton helpBtn = new JButton("帮助");
|
||||||
|
helpBtn.setToolTipText("使用说明");
|
||||||
|
helpBtn.addActionListener(e -> showHelpDialog());
|
||||||
|
|
||||||
|
JButton aboutBtn = new JButton("关于");
|
||||||
|
aboutBtn.setToolTipText("关于软件");
|
||||||
|
aboutBtn.addActionListener(e -> showAboutDialog());
|
||||||
|
|
||||||
|
JButton exitBtn = new JButton("退出");
|
||||||
|
exitBtn.setToolTipText("退出程序");
|
||||||
|
exitBtn.addActionListener(e -> System.exit(0));
|
||||||
|
|
||||||
|
toolBar.add(helpBtn);
|
||||||
|
toolBar.add(aboutBtn);
|
||||||
|
toolBar.addSeparator();
|
||||||
|
toolBar.add(exitBtn);
|
||||||
|
|
||||||
add(toolBar, BorderLayout.NORTH);
|
add(toolBar, BorderLayout.NORTH);
|
||||||
}
|
}
|
||||||
@@ -250,6 +242,26 @@ public class ImageDotMarker extends JFrame {
|
|||||||
JLabel statusLabel = (JLabel) statusPanel.getComponent(0);
|
JLabel statusLabel = (JLabel) statusPanel.getComponent(0);
|
||||||
statusLabel.setText(message);
|
statusLabel.setText(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showAboutDialog() {
|
||||||
|
JOptionPane.showMessageDialog(this,
|
||||||
|
"图片标点工具\n" +
|
||||||
|
"版本 1.0\n" +
|
||||||
|
"用于在图片上标记点并导出坐标数据",
|
||||||
|
"关于", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showHelpDialog() {
|
||||||
|
JOptionPane.showMessageDialog(this,
|
||||||
|
"使用说明:\n\n" +
|
||||||
|
"1. 点击'打开'按钮选择要标记的图片\n" +
|
||||||
|
"2. 在图片上点击添加标记点\n" +
|
||||||
|
"3. 双击标记点可编辑名称\n" +
|
||||||
|
"4. 使用缩放按钮调整图片显示大小\n" +
|
||||||
|
"5. 在右侧面板管理标记点(删除、调整顺序)\n" +
|
||||||
|
"6. 点击'导出文本'将标记点坐标导出为CSV文件",
|
||||||
|
"使用说明", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
}
|
||||||
|
|
||||||
private void openImage() {
|
private void openImage() {
|
||||||
JFileChooser fileChooser = new JFileChooser();
|
JFileChooser fileChooser = new JFileChooser();
|
||||||
|
|||||||
Reference in New Issue
Block a user