Java制作 360界面 中间是游览器.docx
- 文档编号:23579073
- 上传时间:2023-05-18
- 格式:DOCX
- 页数:40
- 大小:99.05KB
Java制作 360界面 中间是游览器.docx
《Java制作 360界面 中间是游览器.docx》由会员分享,可在线阅读,更多相关《Java制作 360界面 中间是游览器.docx(40页珍藏版)》请在冰豆网上搜索。
Java制作360界面中间是游览器
Javaswing制作360界面桌面exe文件中间是游览器
效果:
一主窗体(含注册表操作等)
dpackagecom.haoguang.frame;
importjava.awt.AWTException;
importjava.awt.Color;
importjava.awt.MenuItem;
importjava.awt.PopupMenu;
importjava.awt.SystemTray;
importjava.awt.Toolkit;
importjava.awt.TrayIcon;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjava.awt.event.MouseAdapter;
importjava.awt.event.MouseEvent;
importjava.awt.event.WindowEvent;
importjava.awt.event.WindowListener;
importjava.awt.geom.RoundRectangle2D;
importjava.lang.reflect.Constructor;
import.URL;
importjava.rmi.server.Skeleton;
importjava.util.HashMap;
importjava.util.Map;
importjavax.swing.ImageIcon;
importjavax.swing.JFrame;
importjavax.swing.JInternalFrame;
importjavax.swing.JOptionPane;
importjavax.swing.SwingUtilities;
importjavax.swing.UIManager;
importjavax.swing.border.LineBorder;
importponents.JWebBrowser;
importcom.haoguang.imgpanel.ImagePanel;
importcom.haoguang.util.CheckUpdate;
importcom.haoguang.util.ConfigUtil;
importcom.haoguang.util.PropertiesReader;
importcom.haoguang.webBrowser.WebBrowserPanel;
importcom.ice.jni.registry.NoSuchKeyException;
importcom.ice.jni.registry.NoSuchValueException;
importcom.ice.jni.registry.RegStringValue;
importcom.ice.jni.registry.Registry;
importcom.ice.jni.registry.RegistryException;
importcom.ice.jni.registry.RegistryKey;
publicclassMainFrameextendsJFrame{
//创建窗体的Map类型集合对象
privatestaticMap
publicHeadBarheadBar;
ImagePanelbackgroundPanel;//背景面板
publicstaticMenuBarmenuBar;
publicstaticLogoBarlogoBar;
publicstaticWebBrowserPaneljwbPanel;
publicstaticJWebBrowserjwb;
publicstaticURLimgURL;
publicstaticFootBarfootBar;
publicstaticTrayIcontrayIcon;//托盘图标
publicstaticSystemTraytray;//本操作系统托盘的实例
publicstaticStringgetRegValue;//获取注册表中的值
publicstaticStringwuliu_Install;//获取安装的路径
publicstaticStringwuliu_Install_Name="8856Wuliu";//指定安装文件夹的名称
publicMainFrame(){
super();//调用父类构造方法
ConfigUtil.init();
this.setIconImage(Toolkit.getDefaultToolkit().createImage(ConfigUtil.titleIco));
this.setUndecorated(true);//去掉JFrame标题栏
this.setTitle("8856物流在线竞价平台");
this.setBounds(0,0,Toolkit.getDefaultToolkit().getScreenSize().width,Toolkit.getDefaultToolkit().getScreenSize().height-30);
//this.setBounds(100,100,900,600);
this.setLocationRelativeTo(null);//在屏幕正中间显示
//设置该窗体为圆角窗体
com.sun.awt.AWTUtilities.setWindowShape(this,
newRoundRectangle2D.Double(0,0,this.getWidth(),this
.getHeight(),15,15));
backgroundPanel=newImagePanel();
backgroundPanel.setBorder(newLineBorder(Color.black));
headBar=newHeadBar(this);
headBar.setBounds(0,0,this.getWidth(),30);
backgroundPanel.setLayout(null);
jwbPanel=newWebBrowserPanel(this);
jwb=jwbPanel.webBrowser;
jwbPanel.setBounds(2,120,this.getWidth()-4,this.getHeight()-150);
finalStringmainURL=PropertiesReader.getProperty("mainURL");
SwingUtilities.invokeLater(newRunnable(){
publicvoidrun(){
jwb.navigate(mainURL+"/laa/load.jsf?
load=xtGongGao");//打开首页
}
});
logoBar=newLogoBar(this);//创建logo标签面板
menuBar=newMenuBar(this);//创建导航标签面板
footBar=newFootBar(this);//创建底下标签面板
menuBar.setBounds(0,20,this.getWidth(),100);
footBar.setBounds(20,this.getHeight()-40,this.getWidth(),50);
logoBar.setBounds(this.getWidth()-200,20,this.getWidth(),100);
tray=SystemTray.getSystemTray();//获得本操作系统托盘的实例
ImageIconicon=newImageIcon(ConfigUtil.titleIco);//将要显示到托盘中的图标
PopupMenupop=newPopupMenu();//构造一个右键弹出式菜单
finalMenuItemshow=newMenuItem("打开程序");
finalMenuItemexit=newMenuItem("退出程序");
pop.add(show);
pop.add(exit);
trayIcon=newTrayIcon(icon.getImage(),"8856物流在线竞价平台",pop);//实例化托盘图标
trayIcon.addMouseListener(newMouseAdapter(){
publicvoidmouseClicked(MouseEvente){
if(e.getClickCount()==1)//鼠标单击图标
{
if(e.getModifiers()==16){//判断左右键
//tray.remove(trayIcon);//从系统的托盘实例中移除托盘图标
setExtendedState(JFrame.NORMAL);//设置状态为正常
setVisible(true);//显示主窗体
}
}
elseif(e.getClickCount()==2)//鼠标双击图标
{
//tray.remove(trayIcon);//从系统的托盘实例中移除托盘图标
setExtendedState(JFrame.NORMAL);//设置状态为正常
setVisible(true);//显示主窗体
}
}
});
ActionListeneral2=newActionListener(){
publicvoidactionPerformed(ActionEvente){
//退出程序
if(e.getSource()==exit){
setVisible(false);//窗体不可视
dispose();//释放窗体资源
System.exit(0);//退出程序
}
//打开程序
if(e.getSource()==show){
setExtendedState(JFrame.NORMAL);//设置状态为正常
setVisible(true);
}
}
};
show.addActionListener(al2);
exit.addActionListener(al2);
try{
tray.add(trayIcon);
}catch(AWTExceptione1){
//TODOAuto-generatedcatchblock
e1.printStackTrace();
}
backgroundPanel.add(headBar);
backgroundPanel.add(menuBar);
backgroundPanel.add(logoBar);
backgroundPanel.add(jwbPanel);
backgroundPanel.add(footBar);
this.add(backgroundPanel);//将此面板添加到窗体上
this.addWindowListener(newWindowListener(){
publicvoidwindowClosing(WindowEvente){
if(PropertiesReader.getProperty("minTry").equals("true")){
setVisible(false);
}else{
System.exit(0);
}
}
publicvoidwindowActivated(WindowEvente){}
publicvoidwindowClosed(WindowEvente){}
publicvoidwindowDeactivated(WindowEvente){}
publicvoidwindowDeiconified(WindowEvente){}
publicvoidwindowIconified(WindowEvente){}
publicvoidwindowOpened(WindowEvente){}
});
}
publicstaticvoidmain(String[]args){
//版本更新
Stringisneedupdate=newCheckUpdate().doCheckUpdate();
System.out.println(isneedupdate);
if("suc".equals(isneedupdate)){
intcount=JOptionPane.showConfirmDialog(null,"系统检测到您的软件版本有更新,是否更新?
","软件更新",JOptionPane.YES_NO_OPTION);
if(count==JOptionPane.NO_OPTION){
runMainFrame();
return;
}
//JOptionPane.showMessageDialog(null,"系统检测到更新的版本,点击确认后将自动开始升级","版本检测通知",JOptionPane.INFORMATION_MESSAGE);
Stringjds_url=System.getProperty("user.dir")+
System.getProperty("file.separator")+"update.exe";
try{
Processchild=Runtime.getRuntime().exec(jds_url);
}
catch(Exceptionex){
ex.printStackTrace();
}
System.exit(0);
}else{
runMainFrame();
}
}
publicstaticvoidrunMainFrame(){
MainFramecm=newMainFrame();
cm.setVisible(true);
getRegValue=getValue("SOFTWARE","Microsoft\\Windows\\CurrentVersion\\Run",wuliu_Install_Name);
System.out.println(getRegValue);
wuliu_Install=System.getProperty("user.dir")+System.getProperty("file.separator")+wuliu_Install_Name+".exe";
System.out.println(wuliu_Install);
if(PropertiesReader.getProperty("poweredUp").equals("true")){
//如果设置了随机启动但是注册表中没有设置,则在注册表中添加
if(getRegValue.equals("NoSuchKey")||getRegValue.equals("NoSuchValue")){
setValue("SOFTWARE","Microsoft\\Windows\\CurrentVersion\\Run",wuliu_Install_Name,wuliu_Install);
}
}
}
publicstaticJInternalFramegetIFrame(StringframeName){
JInternalFramejf=null;
if(!
ifs.containsKey(frameName)){
try{
ClassfClass=Class.forName("com.haoguang.webBrowser."+frameName);
Constructorconstructor=fClass.getConstructor(null);
jf=(JInternalFrame)constructor.newInstance(null);
ifs.put(frameName,jf);
}catch(Exceptione){
e.printStackTrace();
}
}else
jf=ifs.get(frameName);
returnjf;
}
static{
try{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}catch(Exceptione){
e.printStackTrace();
}
}
publicstaticStringgetAppPath(Classcls){
//检查用户传入的参数是否为空
if(cls==null)
thrownewjava.lang.IllegalArgumentException("参数不能为空!
");
ClassLoaderloader=cls.getClassLoader();
//获得类的全名,包括包名
StringclsName=cls.getName()+".class";
//获得传入参数所在的包
Packagepack=cls.getPackage();
Stringpath="";
//如果不是匿名包,将包名转化为路径
if(pack!
=null){
StringpackName=pack.getName();
//此处简单判定是否是Java基础类库,防止用户传入JDK内置的类库
if(packName.startsWith("java.")||packName.startsWith("javax."))
thrownewjava.lang.IllegalArgumentException("不要传送系统类!
");
//在类的名称中,去掉包名的部分,获得类的文件名
clsName=clsName.substring(packName.length()+1);
//判定包名是否是简单包名,如果是,则直接将包名转换为路径,
if(packName.indexOf(".")<0)
path=packName+"/";
else{//否则按照包名的组成部分,将包名转换为路径
intstart=0,end=0;
end=packName.indexOf(".");
while(end!
=-1){
path=path+packName.substring(start,end)+"/";
start=end+1;
end=packName.indexOf(".",start);
}
path=path+packName.substring(start)+"/";
}
}
//调用ClassLoader的getResource方法,传入包含路径信息的类文件名
.URLurl=loader.getResource(path+clsName);
//从URL对象中获取路径信息
StringrealPath=url.getPath();
//去掉路径信息中的协议名"file:
"
intpos=realPath.indexOf("file:
");
if(pos>-1)
realPath=realPath.substring(pos+5);
//去掉路径信息最后包含类文件信息的部分,得到类所在的路径
pos=realPath.indexOf(path+clsName);
realPath=realPath.substring(0,pos-1);
//如果类文件被打包到JAR等文件中时,去掉对应的JAR等打包文件名
if(realPath.endsWith("!
"))
realPath=realPath.substring(0,realPath.lastIndexOf("/"));
try{
realPath=.URLDecoder.decode(realPath,"utf-8");
}catch(Exceptione){
thrownewRuntimeException(e);
}
returnrealPath;
}//
publicstaticbooleansetValue(Stringfolder,StringsubKeyNode,
StringsubKeyName,StringsubKeyValue){
try{
RegistryKeysoftware
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Java 制作 360界面 中间是游览器 360 界面 中间 游览