Package Com.*;import Java.awt.borderlayout;import Java.awt.toolkit;import java.awt.event.mouseevent;import Java.awt.event.mouselistener;import Java.io.file;import Java.util.date;import Javax.swing.ImageIcon;import Javax.swing.jframe;import Javax.swing.jlabel;import Javax.swing.jpanel;import Javax.swing.SwingUtilities;import Chrriis.common.uiutils;import Chrriis.dj.nativeswing.swtimpl.nativeinterface;import Chrriis.dj.nativeswing.swtimpl.components.jwebbrowser;import Chrriis.dj.nativeswing.swtimpl.components.webbrowsercommandevent;import Chrriis.dj.nativeswing.swtimpl.components.webbrowserevent;import Chrriis.dj.nativeswing.swtimpl.components.webbrowserlistener;import Chrriis.dj.nativeswing.swtimpl.components.webbrowsernavigationevent;import Chrriis.dj.nativeswing.swtimpl.components.webbrowserwindowopeningevent;import chrriis.dj.nativeswing.swtimpl.components.webbrowserwindowwillopenevent;/** * Main form * * @author DXM * */public class MainF Rame extends JFrame {private static final long SERialversionuid = -6348199501339114346l;//Last operating time public long lasttime = new Date (). GetTime ();//Browser form private Jwebbrowser W Ebbrowser = null;private JLabel lbl = null;private JPanel panel = null;private int type = 2;/** * constructor */public MainFrame () {InitData (); Initgui (); Addlistance ();} private void InitData () {Toolkit Toolkit = Toolkit.getdefaulttoolkit (); This.seticonimage (New ImageIcon ( System.getproperty ("User.dir") + "\\5.jpg"). GetImage ()); this.setundecorated (true); This.setdefaultcloseoperation ( Jframe.exit_on_close); This.setsize (n), this.setlocationrelativeto (null); This.setsize ( Toolkit.getscreensize ()); this.setlocation (0, 0); webBrowser = new Jwebbrowser (); webbrowser.navigate (Config.url); Webbrowser.setbarsvisible (false); webbrowser.setmenubarvisible (false); webbrowser.setlocationbarvisible (false); Webbrowser.setbuttonbarvisible (false); webbrowser.setstatusbarvisible (false); ImageIcon icon = new ImageIcon ( System.getproperty ("User.dir") + "\\5.jpg"); File img = new file (System.getproperty ("usEr.dir ") +" \ \ "+ config.img), if (Img.exists ()) {icon = new ImageIcon (Img.getabsolutepath ());} LBL = new JLabel (icon);p anel = new JPanel (new BorderLayout ());} private void Initgui () {Panel.add (WebBrowser, Borderlayout.center); This.setcontentpane (panel);} private void Addlistance () {Webbrowser.addwebbrowserlistener (new Webbrowserlistener () {@Overridepublic void Windowwillopen (webbrowserwindowwillopenevent arg0) {lasttime = new Date (). GetTime (); @Overridepublic void windowopening (Webbrowserwindowopeningevent arg0) {lasttime = new Date (). GetTime (); @Overridepublic void windowclosing (Webbrowserevent arg0) {lasttime = new Date (). GetTime (); @Overridepublic void titlechanged (Webbrowserevent arg0) {lasttime = new Date (). GetTime (); @Overridepublic void statuschanged (Webbrowserevent arg0) {lasttime = new Date (). GetTime (); @Overridepublic void locationchanging (Webbrowsernavigationevent arg0) {lasttime = new Date (). GetTime (); @Overridepublic void locationchanged (Webbrowsernavigationevent arg0) {LASTTIME = new Date (). GetTime ();} @Overridepublic void locationchangecanceled (Webbrowsernavigationevent arg0) {lasttime = new Date (). GetTime (); @Overridepublic void loadingprogresschanged (Webbrowserevent arg0) {lasttime = new Date (). GetTime (); @Overridepublic void commandreceived (Webbrowsercommandevent arg0) {lasttime = new Date (). GetTime ();}); Lbl.addmouselistener (New MouseListener () {@Overridepublic void mousereleased (MouseEvent arg0) {} @Overridepublic void mousepressed (MouseEvent arg0) {} @Overridepublic void mouseexited (MouseEvent arg0) {} @Overridepublic void mouseentered ( MouseEvent arg0) {} @Overridepublic void mouseclicked (MouseEvent arg0) {change (2);}});} /** * Screensaver Toggle */public void change (final int type) {lasttime = new Date (). GetTime (); if (type = = This.type) {return;} This.type = type; Swingutilities.invokelater (New Runnable () {public void run () {if (type = = 1) {webbrowser.setvisible (false);p Anel.add ( LBL, borderlayout.center);} else {panel.remove (LBL); webbrowser.setvisible (true);} Panel.valiDate ();}}); public static void Main (string[] args) {uiutils.setpreferredlookandfeel (); Nativeinterface.open (); Swingutilities.invokelater (New Runnable () {public void run () {MainFrame frame = new MainFrame (); frame.setvisible (true); New Changewait (frame). Trystart ();}); Nativeinterface.runeventpump ();}}
Jar Package http://download.csdn.net/detail/daixinmei/7827723
Swing interface Nested browser