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

📄 main.java

📁 手机模拟器源代码,可以在网页上调用applet应用来摸拟手机,在线体验手机游戏和运用.可以在网页上自定义手机外观.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* *  MicroEmulator *  Copyright (C) 2001 Bartek Teodorczyk <barteo@it.pl> * *  This library is free software; you can redistribute it and/or *  modify it under the terms of the GNU Lesser General Public *  License as published by the Free Software Foundation; either *  version 2.1 of the License, or (at your option) any later version. * *  This library is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *  Lesser General Public License for more details. * *  You should have received a copy of the GNU Lesser General Public *  License along with this library; if not, write to the Free Software *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */ package com.barteo.emulator.app;import java.awt.Dimension;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.KeyEvent;import java.awt.event.KeyListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.io.File;import java.net.MalformedURLException;import java.net.URL;import javax.microedition.lcdui.Image;import javax.microedition.midlet.MIDlet;import javax.microedition.midlet.MIDletStateChangeException;import javax.swing.JFileChooser;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JMenu;import javax.swing.JMenuBar;import javax.swing.JMenuItem;import javax.swing.JOptionPane;import javax.swing.LookAndFeel;import javax.swing.UIManager;import com.barteo.emulator.DisplayComponent;import com.barteo.emulator.EmulatorContext;import com.barteo.emulator.MIDletBridge;import com.barteo.emulator.app.launcher.Launcher;import com.barteo.emulator.app.ui.ResponseInterfaceListener;import com.barteo.emulator.app.ui.StatusBarListener;import com.barteo.emulator.app.ui.swing.ExtensionFileFilter;import com.barteo.emulator.app.ui.swing.SwingDeviceComponent;import com.barteo.emulator.app.ui.swing.SwingDialogWindow;import com.barteo.emulator.app.ui.swing.SwingSelectDevicePanel;import com.barteo.emulator.app.util.DeviceEntry;import com.barteo.emulator.app.util.ProgressJarClassLoader;import com.barteo.emulator.device.Device;import com.barteo.emulator.device.DeviceDisplay;import com.barteo.emulator.device.DeviceFactory;import com.barteo.emulator.device.FontManager;import com.barteo.emulator.device.InputMethod;import com.barteo.emulator.device.j2se.J2SEDeviceDisplay;import com.barteo.emulator.device.j2se.J2SEFontManager;import com.barteo.emulator.device.j2se.J2SEInputMethod;public class Main extends JFrame{  Main instance = null;    protected Common common;    protected boolean initialized = false;    SwingSelectDevicePanel selectDevicePanel = null;  JFileChooser fileChooser = null;  JMenuItem menuOpenJADFile;  JMenuItem menuOpenJADURL;	JMenuItem menuSelectDevice;	      SwingDeviceComponent devicePanel;  DeviceEntry deviceEntry;  JLabel statusBar = new JLabel("Status");    private EmulatorContext emulatorContext = new EmulatorContext()  {    private ProgressJarClassLoader loader = new ProgressJarClassLoader();        private InputMethod inputMethod = new J2SEInputMethod();        private DeviceDisplay deviceDisplay = new J2SEDeviceDisplay(this);        private FontManager fontManager = new J2SEFontManager();        public ClassLoader getClassLoader()    {      return loader;    }        public DisplayComponent getDisplayComponent()    {      return devicePanel.getDisplayComponent();    }	public Launcher getLauncher() 	{		return common.getLauncher();	}    public InputMethod getDeviceInputMethod()    {        return inputMethod;    }    public DeviceDisplay getDeviceDisplay()    {        return deviceDisplay;    }	public FontManager getDeviceFontManager() 	{		return fontManager;	}      };    KeyListener keyListener = new KeyListener()  {        public void keyTyped(KeyEvent e)    {    }        public void keyPressed(KeyEvent e)    {      devicePanel.keyPressed(e);    }        public void keyReleased(KeyEvent e)    {      devicePanel.keyReleased(e);    }      };     ActionListener menuOpenJADFileListener = new ActionListener()  {    public void actionPerformed(ActionEvent ev)    {      if (fileChooser == null) {        ExtensionFileFilter fileFilter = new ExtensionFileFilter("JAD files");        fileFilter.addExtension("jad");        fileChooser = new JFileChooser();        fileChooser.setFileFilter(fileFilter);        fileChooser.setDialogTitle("Open JAD File...");      }            int returnVal = fileChooser.showOpenDialog(instance);      if (returnVal == JFileChooser.APPROVE_OPTION) {      	try {	      	common.openJadFile(fileChooser.getSelectedFile().toURL());				} catch (MalformedURLException ex) {					System.err.println("Bad URL format " + fileChooser.getSelectedFile().getName());				}      }    }   };    ActionListener menuOpenJADURLListener = new ActionListener()  {    public void actionPerformed(ActionEvent ev)    {      String entered = JOptionPane.showInputDialog(instance, "Enter JAD URL:");      if (entered != null) {      	try {					URL url = new URL(entered);					common.openJadFile(url);				} catch (MalformedURLException ex) {					System.err.println("Bad URL format " + entered);      	}      }    }      };    ActionListener menuExitListener = new ActionListener()  {        public void actionPerformed(ActionEvent e)    {      System.exit(0);    }      };      ActionListener menuSelectDeviceListener = new ActionListener()  {        public void actionPerformed(ActionEvent e)    {      if (SwingDialogWindow.show(instance, "Select device...", selectDevicePanel)) {        if (selectDevicePanel.getSelectedDeviceEntry().equals(getDevice())) {          return;        }        if (MIDletBridge.getCurrentMIDlet() != common.getLauncher()) {          if (JOptionPane.showConfirmDialog(instance,               "Changing device needs MIDlet to be restarted. All MIDlet data will be lost. Are you sure?",               "Question?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != 0) {            return;          }        }        setDevice(selectDevicePanel.getSelectedDeviceEntry());        if (MIDletBridge.getCurrentMIDlet() != common.getLauncher()) {          try {            MIDlet result = (MIDlet) MIDletBridge.getCurrentMIDlet().getClass().newInstance();            common.startMidlet(result);          } catch (Exception ex) {            System.err.println(ex);          }        } else {          common.startMidlet(common.getLauncher());        }      }    }      };    StatusBarListener statusBarListener = new StatusBarListener()  {		public void statusBarChanged(String text) 		{			statusBar.setText(text);		}    };  	ResponseInterfaceListener responseInterfaceListener = new ResponseInterfaceListener()	{		public void stateChanged(boolean state) 		{			menuOpenJADFile.setEnabled(state);			menuOpenJADURL.setEnabled(state);			menuSelectDevice.setEnabled(state);		}  	};  	WindowAdapter windowListener = new WindowAdapter()	{		public void windowClosing(WindowEvent ev) 

⌨️ 快捷键说明

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