menubarprovider.java

来自「用Swing实现的CHM制作工具」· Java 代码 · 共 84 行

JAVA
84
字号
package g2w.app.gchm.gui;

import g2w.app.gchm.GChm;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JSeparator;

/**
 * MenuBarProvider is used to provider menubars for GCHMCreator.
 * 
 * @author GreatGhoul
 * @version 003 2009-3-21 22:41:32
 */
public class MenuBarProvider {
	/**
	 * Prevent being instanced.
	 */
	private MenuBarProvider() {}
	
	/**
	 * Return the main menubar.
	 * 
	 * @return The main menubar.
	 */
	public static JMenuBar getMainMenuBar() {
		JMenuBar menubar = new JMenuBar();
		
		// File menu.
		JMenu fileMenu = new JMenu("文件");
		
		// Create a project.
		fileMenu.add(GChm.getAction("NewProject"));	
		
		// Open a project.
		fileMenu.add(GChm.getAction("OpenProject"));
	
		// Save the project.
		fileMenu.add(GChm.getAction("SaveProject"));
		
		// Close the project.
		fileMenu.add(GChm.getAction("CloseProject"));
		
		fileMenu.add(new JSeparator());
		
		// Set the workspace.
		fileMenu.add(GChm.getAction("SetWorkspace"));
		fileMenu.add(new JSeparator());
		
		// Exit the application
		fileMenu.add(GChm.getAction("Exit"));
		
		menubar.add(fileMenu);
		
		
		// The view menu.
		JMenu viewMenu = new JMenu("视图");
		
		// Show the console.
		viewMenu.add(GChm.getAction("ShowConsole"));
		
		menubar.add(viewMenu);
		
		// The project menu.
		JMenu projectMenu = new JMenu("工程");
		
		// Compile the project.
		projectMenu.add(GChm.getAction("CompileProject"));
		projectMenu.add(GChm.getAction("OpenProjectFolder"));
		menubar.add(projectMenu);
		
		// The help menu.
		JMenu helpMenu = new JMenu("帮助");
		
		// Show the about dialog.
		helpMenu.add(GChm.getAction("ShowAbout"));
		// Visit the website.
		helpMenu.add(GChm.getAction("VisitWebsite"));
		menubar.add(helpMenu);
		
		return menubar;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?