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

📄 browserframe.java

📁 java调用ie浏览器demo源码,可以用在windows或者linux
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*

 * Copyright (C) 2008 Sun Microsystems, Inc. All rights reserved. Use is

 * subject to license terms.

 *

 * This program is free software; you can redistribute it and/or modify

 * it under the terms of the Lesser GNU General Public License as

 * published by the Free Software Foundation; either version 2 of the

 * License, or (at your option) any later version.

 *

 * This program 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

 * General Public License for more details.

 *

 * You should have received a copy of the GNU General Public License

 * along with this program; if not, write to the Free Software

 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

 * USA.

 */



import java.awt.Rectangle;

import javax.swing.JOptionPane;

import org.jdic.web.BrXMLTree;

import org.jdic.web.event.BrComponentEvent;

import org.jdic.web.event.BrComponentListener;

import org.w3c.dom.Node;





/**

 * Sample browser implementation.

 * @author  uta

 */

public class BrowserFrame extends javax.swing.JFrame

implements BrComponentListener

{



    /** Creates new form BrowserFrame */

    public BrowserFrame() {

        org.jdic.web.BrComponent.DESIGN_MODE = false;

        initComponents();

        brMain.addBrComponentListener(this);

    }



    /** This method is called from within the constructor to

     * initialize the form.

     * WARNING: Do NOT modify this code. The content of this method is

     * always regenerated by the Form Editor.

     */

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents

    private void initComponents() {

        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();



        jPopupMenu1 = new javax.swing.JPopupMenu();

        jPanel1 = new javax.swing.JPanel();

        jSplitPane1 = new javax.swing.JSplitPane();

        jPanel2 = new javax.swing.JPanel();

        bnRefresh = new javax.swing.JButton();

        jScrollPane1 = new javax.swing.JScrollPane();

        brXMLTree = new org.jdic.web.BrXMLTree();

        brMain = new org.jdic.web.BrComponent();

        ieToolBar = new javax.swing.JToolBar();

        bnBack = new javax.swing.JButton();

        bnForward = new javax.swing.JButton();

        bnReload = new javax.swing.JButton();

        bnStop = new javax.swing.JButton();

        lbURL = new javax.swing.JLabel();

        edAddress = new javax.swing.JTextField();

        bnGo = new javax.swing.JButton();

        ieStatus = new javax.swing.JToolBar();

        edStatusText = new javax.swing.JTextField();

        bnLocker = new javax.swing.JButton();

        pbDownloadDoc = new javax.swing.JProgressBar();

        mainJMenuBar = new javax.swing.JMenuBar();

        fileJMenu = new javax.swing.JMenu();

        miOpen = new javax.swing.JMenuItem();

        miSave = new javax.swing.JMenuItem();

        miPrint = new javax.swing.JMenuItem();

        jSeparator1 = new javax.swing.JSeparator();

        miExit = new javax.swing.JMenuItem();

        toolsJMenu = new javax.swing.JMenu();

        cmiTraceRedraw = new javax.swing.JCheckBoxMenuItem();



        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        setIconImage(new javax.swing.ImageIcon(getClass().getResource("/images/reload.png")).getImage());



        org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ, brMain, org.jdesktop.beansbinding.ELProperty.create("${windowTitle}"), this, org.jdesktop.beansbinding.BeanProperty.create("title"));

        binding.setSourceNullValue("Simple Java Browser");

        bindingGroup.addBinding(binding);



        jPanel1.setLayout(new java.awt.BorderLayout());



        jSplitPane1.setDividerLocation(300);

        jSplitPane1.setResizeWeight(1.0);

        jSplitPane1.setMinimumSize(new java.awt.Dimension(100, 100));



        jPanel2.setPreferredSize(new java.awt.Dimension(0, 0));

        jPanel2.setRequestFocusEnabled(false);



        bnRefresh.setText("Create DOM view");

        bnRefresh.setFocusable(false);

        bnRefresh.setHorizontalAlignment(javax.swing.SwingConstants.LEADING);

        bnRefresh.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        bnRefresh.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);



        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, brMain, org.jdesktop.beansbinding.ELProperty.create("${documentReady}"), bnRefresh, org.jdesktop.beansbinding.BeanProperty.create("enabled"));

        bindingGroup.addBinding(binding);



        bnRefresh.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                bnRefreshActionPerformed(evt);

            }

        });



        brXMLTree.addTreeWillExpandListener(new javax.swing.event.TreeWillExpandListener() {

            public void treeWillExpand(javax.swing.event.TreeExpansionEvent evt)throws javax.swing.tree.ExpandVetoException {

                brXMLTreeTreeWillExpand(evt);

            }

            public void treeWillCollapse(javax.swing.event.TreeExpansionEvent evt)throws javax.swing.tree.ExpandVetoException {

            }

        });

        brXMLTree.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {

            public void valueChanged(javax.swing.event.TreeSelectionEvent evt) {

                brXMLTreeValueChanged(evt);

            }

        });

        jScrollPane1.setViewportView(brXMLTree);



        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);

        jPanel2.setLayout(jPanel2Layout);

        jPanel2Layout.setHorizontalGroup(

            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addGroup(jPanel2Layout.createSequentialGroup()

                .addComponent(bnRefresh)

                .addContainerGap(148, Short.MAX_VALUE))

            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE)

        );

        jPanel2Layout.setVerticalGroup(

            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addGroup(jPanel2Layout.createSequentialGroup()

                .addComponent(bnRefresh)

                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE))

        );



        bnRefresh.getAccessibleContext().setAccessibleName("bnRefresh");



        jSplitPane1.setRightComponent(jPanel2);



        brMain.setURL("http://java.net");

        brMain.setPreferredSize(new java.awt.Dimension(220, 220));



        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cmiTraceRedraw, org.jdesktop.beansbinding.ELProperty.create("${selected}"), brMain, org.jdesktop.beansbinding.BeanProperty.create("doubleBuffered"));

        bindingGroup.addBinding(binding);



        brMain.addPropertyChangeListener(new java.beans.PropertyChangeListener() {

            public void propertyChange(java.beans.PropertyChangeEvent evt) {

                onBrowserPropertyChange(evt);

            }

        });



        javax.swing.GroupLayout brMainLayout = new javax.swing.GroupLayout(brMain);

        brMain.setLayout(brMainLayout);

        brMainLayout.setHorizontalGroup(

            brMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addGap(0, 299, Short.MAX_VALUE)

        );

        brMainLayout.setVerticalGroup(

            brMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addGap(0, 503, Short.MAX_VALUE)

        );



        jSplitPane1.setLeftComponent(brMain);



        jPanel1.add(jSplitPane1, java.awt.BorderLayout.CENTER);



        ieToolBar.setRollover(true);



        bnBack.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/back.png"))); // NOI18N

        bnBack.setToolTipText("Go back one page");

        bnBack.setFocusable(false);

        bnBack.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        bnBack.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);



        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, brMain, org.jdesktop.beansbinding.ELProperty.create("${goBackEnable}"), bnBack, org.jdesktop.beansbinding.BeanProperty.create("enabled"));

        bindingGroup.addBinding(binding);



        bnBack.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                bnBackActionPerformed(evt);

            }

        });

        ieToolBar.add(bnBack);



        bnForward.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/forward.png"))); // NOI18N

        bnForward.setToolTipText("Go forward one page");

        bnForward.setFocusable(false);

        bnForward.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        bnForward.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);



        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, brMain, org.jdesktop.beansbinding.ELProperty.create("${goForwardEnable}"), bnForward, org.jdesktop.beansbinding.BeanProperty.create("enabled"));

        bindingGroup.addBinding(binding);



        bnForward.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                bnForwardActionPerformed(evt);

            }

        });

        ieToolBar.add(bnForward);



        bnReload.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/reload.png"))); // NOI18N

        bnReload.setToolTipText("Reload current page");

        bnReload.setFocusable(false);

        bnReload.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        bnReload.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        bnReload.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                bnReloadActionPerformed(evt);

            }

        });

        ieToolBar.add(bnReload);



        bnStop.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/stop.png"))); // NOI18N

        bnStop.setToolTipText("Reload current page");

        bnStop.setFocusable(false);

        bnStop.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        bnStop.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        bnStop.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                bnStopActionPerformed(evt);

            }

        });

        ieToolBar.add(bnStop);



        lbURL.setText(" URL:");

        ieToolBar.add(lbURL);



        edAddress.setText("http://");

        edAddress.setToolTipText("URL for navigation");

        edAddress.setPreferredSize(new java.awt.Dimension(400, 20));

        edAddress.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                onNavigate(evt);

            }

        });

        ieToolBar.add(edAddress);



        bnGo.setText("Go");

        bnGo.setToolTipText("Go to entered URL");

        bnGo.setFocusable(false);

        bnGo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        bnGo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        bnGo.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                onNavigate(evt);

            }

        });

        ieToolBar.add(bnGo);



        jPanel1.add(ieToolBar, java.awt.BorderLayout.PAGE_START);



        ieStatus.setFloatable(false);

        ieStatus.setRollover(true);

        ieStatus.setMaximumSize(new java.awt.Dimension(65536, 20));

        ieStatus.setMinimumSize(new java.awt.Dimension(10, 20));



        edStatusText.setEditable(false);

        edStatusText.setMaximumSize(new java.awt.Dimension(2147483647, 20));



        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ, brMain, org.jdesktop.beansbinding.ELProperty.create("${statusText}"), edStatusText, org.jdesktop.beansbinding.BeanProperty.create("text"));

        bindingGroup.addBinding(binding);



        edStatusText.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                edStatusTextActionPerformed(evt);

            }

        });

        ieStatus.add(edStatusText);



        bnLocker.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/locker.png"))); // NOI18N

        bnLocker.setFocusable(false);

        bnLocker.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        bnLocker.setMaximumSize(new java.awt.Dimension(20, 20));

        bnLocker.setMinimumSize(new java.awt.Dimension(20, 20));

        bnLocker.setPreferredSize(new java.awt.Dimension(20, 20));

        bnLocker.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        bnLocker.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                bnLockerActionPerformed(evt);

            }

        });

        ieStatus.add(bnLocker);



        pbDownloadDoc.setMaximumSize(new java.awt.Dimension(100, 16));

        pbDownloadDoc.setPreferredSize(new java.awt.Dimension(100, 16));

        ieStatus.add(pbDownloadDoc);



        jPanel1.add(ieStatus, java.awt.BorderLayout.PAGE_END);



        fileJMenu.setText("File");

        fileJMenu.setToolTipText("File Operations");



        miOpen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));

        miOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/open.png"))); // NOI18N

        miOpen.setText("Open File...");

        miOpen.setToolTipText("Opens a document in this window");

        miOpen.addActionListener(new java.awt.event.ActionListener() {

⌨️ 快捷键说明

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