⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wmvcapp.java

📁 一个简单的浏览器
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

public abstract class WmvcApp{
		private static WmvcApp theApp=null;
		private static WmvcModel theModel=null;
		
		private static JFrame theFrame=null;//the top window
		private static JPanel theContentPanel=null;
		private static JMenuBar theMenuBar=null;
		private static JToolBar theToolBar=null;
		
		public static JFrame getFrame(){
				return theFrame;
			}
		public static JPanel getContentPanel(){
				return theContentPanel;
			}
		public static JMenuBar getMenuBar(){
				return theMenuBar;
			}
		public static JToolBar getToolBar(){
				return theToolBar;
			}
		public static WmvcModel getModel(){
				return theModel;
			}
		public static void setModel(WmvcModel m){
				theModel=m;
			}
		public static WmvcApp getApp(){
				return theApp;
			}
			
			
		public WmvcApp(String name,boolean cMenu,boolean cTool){
				if(theApp!=null)
					return;
				initial(name,cMenu,cTool);	
			}
		private void initial(String name,boolean cMenu,boolean cTool){
				theFrame=new JFrame(name);
				theFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
				theFrame.addWindowListener(new WindowAdapter(){
						public void windowClosing(WindowEvent e){
							if(theApp.appClosing()==true)
								System.exit(0);
						}
					});
					
				if(cMenu){
					theMenuBar=new JMenuBar();
					theFrame.setJMenuBar(theMenuBar);
				}
				
				theContentPanel=new JPanel();
				theContentPanel.setLayout(new BorderLayout());
				theContentPanel.setPreferredSize(new Dimension(400,300));
				
				if(cTool){
					theToolBar=new JToolBar();
					theContentPanel.add(theToolBar,BorderLayout.NORTH);
				}
				
				theFrame.setContentPane(theContentPanel);
			}
			
			public static void addMainPane(JComponent p){
				theContentPanel.add(p,BorderLayout.SOUTH);
			}
			
			public static void addMenu(JMenu m){
				if(theMenuBar==null)
					return;
				theMenuBar.add(m);	
			}
			
			public static void showApp(){
				theFrame.pack();
				theFrame.setVisible(true);
			}
			
			public static boolean appClosing(){
				return true;
			}
	} 

⌨️ 快捷键说明

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