Java制作 360界面 中間是游覽器_第1頁
Java制作 360界面 中間是游覽器_第2頁
Java制作 360界面 中間是游覽器_第3頁
Java制作 360界面 中間是游覽器_第4頁
Java制作 360界面 中間是游覽器_第5頁
已閱讀5頁,還剩43頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、Java 制作 360界面 中間是游覽器Java swing造做360界里桌里exe文件兩頭是巡游器動機:一主窗體(露注冊表操縱等)dpackage com.haoguang.frame;import java.awt.AWTException;import java.awt.Color;import java.awt.MenuItem;import java.awt.PopupMenu;import java.awt.SystemTray;import java.awt.Toolkit;import java.awt.TrayIcon;import java.awt.event.Action

2、Event;import java.awt.event.ActionListener;import java.awt.event.MouseAdapter;import java.awt.event.MouseEvent;import java.awt.event.WindowEvent;import java.awt.event.WindowListener;import java.awt.geom.RoundRectangle2D;import /doc/f0e2356fa98271fe910ef9f5.htmlng.reflect.Construct

3、or;import /doc/f0e2356fa98271fe910ef9f5.html.URL;import java.rmi.server.Skeleton;import java.util.HashMap;import java.util.Map;import javax.swing.ImageIcon;import javax.swing.JFrame;import javax.swing.JInternalFrame;import javax.swing.JOptionPane;import javax.swing.SwingUtilities;

4、import javax.swing.UIManager;import javax.swing.border.LineBorder;import /doc/f0e2356fa98271fe910ef9f5.htmlponents.JWebBrowser;import com.haoguang.imgpanel.ImagePanel;import com.haoguang.util.CheckUpdate;import com.haoguang.util.ConfigUtil;import com.haoguang.util.PropertiesReader

5、;import com.haoguang.webBrowser.WebBrowserPanel;import com.ice.jni.registry.NoSuchKeyException;import com.ice.jni.registry.NoSuchValueException;import com.ice.jni.registry.RegStringValue;import com.ice.jni.registry.Registry;import com.ice.jni.registry.RegistryException;import com.ice.jni.registry.Re

6、gistryKey;public class MainFrame extends JFrame/ 創立窗體的Map范例散開對于象private static Mappublic HeadBar headBar;ImagePanel backgroundPanel;/后臺里板public static MenuBar menuBar;public static LogoBar logoBar;public static WebBrowserPanel jwbPanel;public static JWebBrowser jwb;public static URL imgURL;public st

7、atic FootBar footBar;public static TrayIcon trayIcon; / 托盤圖標public static SystemTray tray; / 本操縱體系托盤的真例public static String getRegValue;/獵取注冊表中的值public static String wuliu_Install;/獵取安置的途徑public static String wuliu_Install_Name=8856Wuliu; /指定安置文件夾的稱號public MainFrame() super();/ 挪用女類機關圓法ConfigUtil.in

8、it();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

9、,100,900,600);this.setLocationRelativeTo(null);/ 正在屏幕正兩頭隱示/ 配置該窗體為圓角窗體com.sun.awt.AWTUtilities.setWindowShape(this,new RoundRectangle2D.Double(0, 0, this.getWidth(), this.getHeight(), 15, 15);backgroundPanel = new ImagePanel();backgroundPanel.setBorder(new LineBorder(Color.black);headBar = new HeadB

10、ar(this);headBar.setBounds(0, 0, this.getWidth(), 30);backgroundPanel.setLayout(null);jwbPanel=new WebBrowserPanel(this);jwb=jwbPanel.webBrowser;jwbPanel.setBounds(2, 120, this.getWidth()-4,this.getHeight()-150);final String mainURL=PropertiesReader.getProperty(mainURL);SwingUtilities.invokeLater(ne

11、w Runnable() public void run() jwb.navigate(mainURL+/laa/load.jsf?load=xtGongGao);/挨開頭頁);logoBar=new LogoBar(this); / 創立logo標簽里板menuBar = new MenuBar(this); / 創立導航標簽里板footBar = new FootBar(this); / 創立底下標簽里板menuBar.setBounds(0, 20, this.getWidth(), 100);footBar.setBounds(20, this.getHeight()-40, this

12、.getWidth(), 50);logoBar.setBounds(this.getWidth()-200, 20, this.getWidth(), 100);tray = SystemTray.getSystemTray(); / 取得本操縱體系托盤的真例ImageIcon icon = new ImageIcon(ConfigUtil.titleIco); / 將要隱示到托盤中的圖標PopupMenu pop = new PopupMenu(); / 機關一個左鍵彈出式菜單final MenuItem show = new MenuItem(挨開步伐);final MenuItem e

13、xit = new MenuItem(加入步伐);pop.add(show);pop.add(exit);trayIcon = new TrayIcon(icon.getImage(), 8856物流正在線競價仄臺, pop);/ 真例化托盤圖標trayIcon.addMouseListener(new MouseAdapter() public void mouseClicked(MouseEvent e) if (e.getClickCount() = 1)/ 鼠標單擊圖標if(e.getModifiers()=16)/判別擺布鍵/ tray.remove(trayIcon); / 從體系

14、的托盤真例中移除了托盤圖標setExtendedState(JFrame.NORMAL);/ 配置形態為一般setVisible(true);/ 隱示主窗體else if (e.getClickCount() = 2)/ 鼠標單擊圖標/ tray.remove(trayIcon); / 從體系的托盤真例中移除了托盤圖標setExtendedState(JFrame.NORMAL);/ 配置形態為一般setVisible(true);/ 隱示主窗體);ActionListener al2 = new ActionListener() public void actionPerformed(Act

15、ionEvent e) / 加入步伐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 (AWTException e

16、1) / TODO Auto-generated catch blocke1.printStackTrace();backgroundPanel.add(headBar);backgroundPanel.add(menuBar);backgroundPanel.add(logoBar);backgroundPanel.add(jwbPanel);backgroundPanel.add(footBar);this.add(backgroundPanel);/將此里板加減到窗體上this.addWindowListener(new WindowListener()public void windo

17、wClosing(WindowEvent e) if(PropertiesReader.getProperty(minTry).equals(true)setVisible(false);elseSystem.exit(0);public void windowActivated(WindowEvent e) public void windowClosed(WindowEvent e) public void windowDeactivated(WindowEvent e) public void windowDeiconified(WindowEvent e) public void wi

18、ndowIconified(WindowEvent e) public void windowOpened(WindowEvent e) );public static void main(String args) /版本更新String isneedupdate = new CheckUpdate().doCheckUpdate();System.out.println(isneedupdate);if(suc.equals(isneedupdate)int count=JOptionPane.showConfirmDialog(null, 體系檢測到你的硬件版本有更新,是不是更新?, 硬件

19、更新, JOptionPane.YES_NO_OPTION);if(count=JOptionPane.NO_OPTION)runMainFrame();return;/ JOptionPane.showMessageDialog(null, 體系檢測到更新的版本,面擊確認后將主動入手下手降級,版本檢測關照, /doc/f0e2356fa98271fe910ef9f5.htmlRMATION_MESSAGE);String jds_url = System.getProperty(user.dir) +System.getProperty(file.sep

20、arator) + update.exe;try Process child = Runtime.getRuntime().exec(jds_url);catch (Exception ex) ex.printStackTrace();System.exit(0);elserunMainFrame();public static void runMainFrame()MainFrame cm=new MainFrame();cm.setVisible(true);getRegValue=getValue(SOFTWARE, MicrosoftWindowsCurrentVersionRun,

21、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

22、(NoSuchKey)|getRegValue.equals(NoSuchValue)setValue(SOFTWARE, MicrosoftWindowsCurrentVersionRun, wuliu_Install_Name,wuliu_Install);public static JInternalFrame getIFrame(String frameName) JInternalFrame jf = null;if (!ifs.containsKey(frameName) try Class fClass = Class.forName(com.haoguang.webBrowse

23、r.+frameName);Constructor constructor = fClass.getConstructor(null);jf = (JInternalFrame) constructor.newInstance(null);ifs.put(frameName, jf); catch (Exception e) e.printStackTrace(); elsejf = ifs.get(frameName);return jf;static try UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()

24、; catch (Exception e) e.printStackTrace();public static String getAppPath(Class cls) /反省用戶傳進的參數是不是為空if (cls = null)throw new /doc/f0e2356fa98271fe910ef9f5.htmlng.IllegalArgumentException(參數沒有能為空!);ClassLoader loader = cls.getClassLoader();/取得類的齊名,包含包名String clsName = cls.getName()

25、 + .class;/取得傳進參數地點的包Package pack = cls.getPackage();String path = ;/假如沒有是藏名包,將包名轉化為途徑if (pack != null) String packName = pack.getName();/此處復雜判斷是不是是Java基本類庫,避免用戶傳進JDK內置的類庫if (packName.startsWith(java.) | packName.startsWith(javax.)throw new /doc/f0e2356fa98271fe910ef9f5.htmlng.Ill

26、egalArgumentException(沒有要傳遞體系類!);/正在類的稱號中,往失落包名的全體,取得類的文件名clsName = clsName.substring(packName.length() + 1);/判斷包名是不是是復雜包名,假如是,則曲接將包名轉換為途徑,if (packName.indexOf(.) path = packName + /;else /可則依照包名的構成全體,將包名轉換為途徑int start = 0, end = 0;end = packName.indexOf(.);while (end != -1) path = path + packName.s

27、ubstring(start, end) + /;start = end + 1;end = packName.indexOf(., start);path = path + packName.substring(start) + /;/挪用ClassLoader的getResource圓法,傳進包孕途徑疑息的類文件名/doc/f0e2356fa98271fe910ef9f5.html.URL url = loader.getResource(path + clsName);/從URL對于象中獵取途徑疑息String realPath = url.getP

28、ath();/往失落途徑疑息中的協定名file:int pos = 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.su

29、bstring(0, /doc/f0e2356fa98271fe910ef9f5.htmlstIndexOf(/);try realPath = /doc/f0e2356fa98271fe910ef9f5.html.URLDecoder.decode(realPath, utf-8); catch (Exception e) throw new RuntimeException(e);return realPath;/public static boolean setValue(String folder, Strin

30、g subKeyNode,String subKeyName, String subKeyValue) try RegistryKey software = Registry.HKEY_LOCAL_MACHINE.openSubKey(folder);RegistryKey subKey = software.createSubKey(subKeyNode, );subKey.setValue(new RegStringValue(subKey, subKeyName,subKeyValue);subKey.closeKey();return true; catch (NoSuchKeyExc

31、eption e) e.printStackTrace(); catch (NoSuchValueException e) e.printStackTrace(); catch (RegistryException e) e.printStackTrace();return false;/ 刪除了注冊表中某節面下的某個變量public static boolean deleteValue(String folder, String subKeyNode, String subKeyName) try RegistryKey software = Registry.HKEY_LOCAL_MACH

32、INE.openSubKey(folder);RegistryKey subKey = software.createSubKey(subKeyNode, );subKey.deleteValue(subKeyName);subKey.closeKey();return true; catch (NoSuchKeyException e) System.out.println(NOsuchKey_delete); catch (NoSuchValueException e) System.out.println(NOsuchValue_delete); catch (RegistryExcep

33、tion e) e.printStackTrace();return false;/ 刪除了注冊表中某節面下的某節面public static boolean deleteSubKey(String folder, String subKeyNode) try RegistryKey software = Registry.HKEY_LOCAL_MACHINE.openSubKey(folder);software.deleteSubKey(subKeyNode);software.closeKey();return true; catch (NoSuchKeyException e) e.p

34、rintStackTrace(); catch (RegistryException e) e.printStackTrace();return false;/ 挨開注冊表項并讀出響應的變量名的值public static String getValue(String folder, String subKeyNode,String subKeyName) String value = ;try RegistryKey software = Registry.HKEY_LOCAL_MACHINE.openSubKey(folder);RegistryKey subKey = software.

35、openSubKey(subKeyNode);value = subKey.getStringValue(subKeyName);subKey.closeKey(); catch (NoSuchKeyException e) value = NoSuchKey;/ e.printStackTrace(); catch (NoSuchValueException e) value = NoSuchValue;/ e.printStackTrace(); catch (RegistryException e) e.printStackTrace();return value;2:頭部按鈕packa

36、ge com.haoguang.frame;import java.awt.BorderLayout;import java.awt.Color;import java.awt.Cursor;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.GridLayout;import java.awt.Insets;import java.awt.Point;import java.awt.Toolkit;import java.awt.event.ActionEvent;import ja

37、va.awt.event.ActionListener;import java.awt.event.ItemEvent;import java.awt.event.ItemListener;import java.awt.event.MouseEvent;import java.awt.event.WindowEvent;import java.awt.event.WindowListener;import java.awt.geom.RoundRectangle2D;import javax.swing.AbstractAction;import javax.swing.Action;imp

38、ort javax.swing.ButtonGroup;import javax.swing.Icon;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JComponent;import javax.swing.JDialog;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JRad

39、ioButton;import javax.swing.SwingUtilities;import javax.swing.event.MouseInputListener;import com.haoguang.button.LimpidButton;import com.haoguang.imgpanel.ImagePanel;import com.haoguang.util.ConfigUtil;import com.haoguang.util.PropertiesReader;public class HeadBar extends JPanel implements ActionLi

40、stener,MouseInputListener public static JLabel title;/窗體題目public static JButton skinButton;/切換皮膚按鈕public static JButton cancellation; /刊出按鈕public static JButton windowSet; /體系配置public static JLabel userInfo;LimpidButton close, small, max;/ 最小化以及閉閉按鈕(那些按鈕為半通明)public static boolean ismax = true;Point

41、point=new Point(0,0);/坐標指針public static int frameWidth;public static int frameHeight;public static int frameWidth2;public static int frameHeight2;int clickTimes=0;public static boolean allowDrg=true; /判別是不是能夠拖動public MainFrame mainFrame;public String bgSkin=null;public String bgImgButton=null;public

42、 JButton imgBnt;public String mainPanelImg;public Icon icon;public Icon icon2;public ImagePanel jp;public JDialog jd;public JPanel jp2;public ImagePanel jpWindow;public JDialog jdWindow;public JPanel jpWindow2;public HeadBar(MainFrame frame) mainFrame=frame;frameWidth=mainFrame.getWidth();frameHeigh

43、t=mainFrame.getHeight();frameWidth2=1024;frameHeight2=600;this.addMouseListener(this);/ 加減鼠標事務this.addMouseMotionListener(this);/ 加減鼠標舉措事務this.setLayout(null);/初初化題目title = new JLabel(8856物流正在線競價仄臺);title.setForeground(Color.white);title.setBounds(10, 5, 140, 15);userInfo=new JLabel(已登錄);userInfo.se

44、tForeground(Color.white);userInfo.setBounds(frameWidth-220, 5, 100, 15);cancellation=new JButton();cancellation.setText(【刊出】);cancellation.setForeground(Color.white);cancellation.setContentAreaFilled(false);cancellation.setOpaque(false);cancellation.setBounds(mainFrame.getWidth()-250, -3, 80, 30);ca

45、ncellation.setCursor(new Cursor(Cursor.HAND_CURSOR);cancellation.setFocusPainted(false);cancellation.setBorderPainted(false);cancellation.setVisible(false);final String mainURL=PropertiesReader.getProperty(mainURL);cancellation.addActionListener(new ActionListener() public void actionPerformed(Actio

46、nEvent e) int count=JOptionPane.showConfirmDialog(null, 請確認是不是要加入登錄, 刊出登錄, JOptionPane.YES_NO_OPTION);if(count=JOptionPane.NO_OPTION)return;SwingUtilities.invokeLater(new Runnable() public void run() MainFrame.jwb.navigate(mainURL+/laa/load.jsf?load=logOut);/挨開頭頁);userInfo.setText(已登錄);if(mainFrame.

47、getWidth()1000)userInfo.setBounds(frameWidth-220, 5, 100, 15);elseuserInfo.setBounds(frameWidth2-220, 5, 100, 15);cancellation.setVisible(false););/初初化皮膚按鈕Icon icon0 = new ImageIcon(ConfigUtil.icon_skin);skinButton = new JButton();skinButton.setMargin(new Insets(0, 0, 0, 0);skinButton.setHideActionT

48、ext(true);skinButton.setFocusPainted(false);skinButton.setBorderPainted(false);skinButton.setContentAreaFilled(false);skinButton.setCursor(new Cursor(Cursor.HAND_CURSOR);skinButton.setIcon(icon0);skinButton.setBounds(mainFrame.getWidth()-165, 1, 20, 19);mainPanelImg=PropertiesReader.getProperty(bgIm

49、g);bgSkin=PropertiesReader.getProperty(bgImgSkin).split(,);bgImgButton=PropertiesReader.getProperty(bgImgButton).split(,);skinButton.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) if(jd=null)jd=new JDialog(mainFrame);jd.getContentPane().setLayout(new BorderLayout()

50、;jd.setIconImage(Toolkit.getDefaultToolkit().createImage(ConfigUtil.titleIco);jd.setTitle(改換皮膚);jd.setResizable(false);jd.setBounds(100, 100, 400, 200);jd.setLocationRelativeTo(null);jd.setVisible(true);jd.setModal(true);skinButton.setEnabled(false);elsejd.setVisible(true);jp=new ImagePanel();/ jp.s

51、etBackground(Color.white);jp2=new JPanel(new GridLayout(2,1);jp2.setOpaque(false);imgBnt=new JButtonbgSkin.length;for(int i=0;iAction action = new skinFrameAction(i,bgImgButtoni,bgSkini);imgBnti=new JButton(action);imgBnti.setMargin(new Insets(0, 0, 0, 0);imgBnti.setHideActionText(true);imgBnti.setF

52、ocusPainted(false);imgBnti.setBorderPainted(false);imgBnti.setContentAreaFilled(false);imgBnti.setCursor(new Cursor(Cursor.HAND_CURSOR);if(bgImgButtoni.equals(mainPanelImg)icon2 = new ImageIcon(res/ActionIcon/ +bgImgButtoni+_down.jpg);imgBnti.setIcon(icon2);jp.setImage(res/ +bgSkini+.jpg);elseicon =

53、 new ImageIcon(res/ActionIcon/ +bgImgButtoni+.jpg);imgBnti.setIcon(icon);jp2.add(imgBnti);jp.add(jp2);jd.add(jp);jd.addWindowListener(new WindowListener()public void windowClosing(WindowEvent e) skinButton.setEnabled(true);jd.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);jd.dispose();jd=null

54、;public void windowActivated(WindowEvent e) public void windowClosed(WindowEvent e) public void windowDeactivated(WindowEvent e) public void windowDeiconified(WindowEvent e) public void windowIconified(WindowEvent e) public void windowOpened(WindowEvent e) ););Icon iconSet = new ImageIcon(ConfigUtil.windowSet);windowSet = new JButton();windowSet.setMargin(new Insets(0, 0, 0, 0);windowSet.setHideActionText(true);windowSet.setFocusPainted(false);windowSet.setBorderPainted(false);windowSet.setContentAreaFilled(false);windowSet.setCursor(new

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論