Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Development-process Java Web Browser Problem
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Sunil Kumar Gahlot
Java Web Browser Problem
0 Answer(s)      a year and 3 months ago
Posted in : Development process


Hello When run my web browser this is not displaying complete page any of the website like other browser.So Plz help me.

package vision.sun;


import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.net.URL;
import java.util.Stack;
import java.util.jar.JarFile;


import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JEditorPane;
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.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;


public class WebBrowser2 {

    @SuppressWarnings("deprecation")
    public static void main(String args[])
    {
        JFrame frame=new EditorPaneFrame();
        frame.show();
    }
}
class EditorPaneFrame extends JFrame
{
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private JTextField url;
    private JCheckBox editable;
    private JButton loadButton;
    private JButton backButton;
    private JEditorPane editorPane;
    private JMenuItem FavAdd;
    JarFile jar;
    private Stack<String> urlStack=new Stack<String>();


    public EditorPaneFrame()
    {
        if(isConnected())
            System.out.println("Proxy Connected.");
        setTitle("NextVision Browser");
        setSize(600,400);
        Container contentPane = getContentPane();

        addWindowListener(new WindowAdapter()  {

            public void windowClosing(WindowEvent e)
            {
                System.exit(0);
            }
        });

        url=new JTextField(30);
        loadButton=new JButton("Load");
        loadButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                try
                {

                    URL netURL=new URL(url.getText());
                    urlStack.push(url.getText());

                    editorPane.setPage(netURL);

                }
                catch(Exception ex)
                {
                    ex.printStackTrace();
                }
            }
        });
        // set up back button and button action
         backButton = new JButton("<<");
         backButton.addActionListener(new ActionListener()
         {
        public void actionPerformed(ActionEvent event)
         {
        if(urlStack.size()<=1) return;
        try
         {
         urlStack.pop();
         String urlString = (String)urlStack.peek();
         url.setText(urlString);
         editorPane.setPage(urlString);
         }
        catch(IOException e)
         {
         editorPane.setText("Error : " +e);
         }
         }
         });

         editorPane = new JEditorPane();
         editorPane.setEditable(false);
         editorPane.addHyperlinkListener(new HyperlinkListener()
         {
        public void hyperlinkUpdate(HyperlinkEvent event)
         {
        if(event.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
         {
        try
         {
         urlStack.push(event.getURL().toString());
         url.setText(event.getURL().toString());
         editorPane.setPage(event.getURL().toString());
         }
        catch(IOException e)
         {
         editorPane.setText("Error: " + e);
         }

         }
         }
         });
         editable = new JCheckBox();
         editable.addActionListener(new ActionListener()
         {
        public void actionPerformed(ActionEvent event)
         {
         editorPane.setEditable(editable.isSelected());
         }
         });

         //referesh=new JButton("Referesh");

         contentPane.add(new JScrollPane(editorPane), "Center");
         JPanel panel = new JPanel();
         panel.add(new JLabel("URL"));
         panel.add(url);
         panel.add(loadButton);
         panel.add(backButton);
         panel.add(new JLabel("Editable"));
         panel.add(editable);
         //panel.setBounds(10, 10, 50, 60);
         JMenuBar objMenuBar=new JMenuBar();
         JMenu objMenu=new JMenu("File");
         JMenu objSetting=new JMenu("Setting");
         JMenu objFavourite=new JMenu("Favourite");
         objMenuBar.add(objMenu);
         objMenuBar.add(objFavourite);
         JMenuItem objMenuItem=new JMenuItem("New");
         JMenuItem objMenuExit=new JMenuItem("Exit");
         JMenuItem OpenRun=new JMenuItem("Open Type");
         objMenu.add(objMenuItem);
         objMenu.add(OpenRun);
         objMenu.add(objMenuExit);
         JMenuItem Internet=new JMenuItem("Connection");
         FavAdd=new JMenuItem("Add Address");
         objMenuBar.add(objSetting);
         objFavourite.add(FavAdd);
         objSetting.add(Internet);

         contentPane.add(panel,"South");
         contentPane.add(objMenuBar,"North");
         FavAdd.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                JOptionPane.showMessageDialog(null, "Program Under Progress !");

            }
        }
                 );
         objMenuExit.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {

                if(JOptionPane.showConfirmDialog(null, "Are You Sure To Exit ?","Message",JOptionPane.CANCEL_OPTION)==0)
                {
                System.exit(0);
                }
            }
        });

         OpenRun.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {

                runCommand();
            }
        });
    }
    private void runCommand()
    {
        String inputCommand=null;
        try
        {
        inputCommand=JOptionPane.showInputDialog(null,"Enter Command Here");
        if(inputCommand!=null)
        {
            Runtime runtime=Runtime.getRuntime();
            runtime.exec(inputCommand);
        }
        }
        catch(Exception ex)
        {
            System.out.println(ex.getMessage());
            if(ex.getMessage().toString().indexOf("The system cannot find the file specified")!=-1)
            {
                JOptionPane.showMessageDialog(null, "Invalid Command !");
                runCommand();
            }
            else if(ex.getMessage().toString().indexOf("Empty command")!=-1)
            {
                JOptionPane.showMessageDialog(null, "Please Enter Command !");
                runCommand();
            }
            else if(ex.getMessage().toString().indexOf("Access is denied")!=-1)
            {
                JOptionPane.showMessageDialog(null, "Invalid Command !");
                runCommand();
            }
            else if(ex.getMessage().toString().indexOf("The parameter is incorrect")!=-1)
            {
                JOptionPane.showMessageDialog(null, "Invalid Command !");
                runCommand();
            }
        }
    }
    private boolean isConnected()
    {

        //System.setProperty("http.proxyHost","10.0.0.3");
        //System.setProperty("http.proxyPort","6588");
        String host=System.getProperty("http.proxyHost");
        String port=System.getProperty("http.proxyPort");
                System.out.println("host is "+host);
                System.out.println("port is "+port);
        System.setProperty("https.proxyHost", "10.0.0.3");
        System.setProperty("https.proxyPort", "6588");
        if(!host.equals("")&&!port.equals(""))
        return true;
        else
        return false;
    }
}

Advertisement
View Answers

Related Tutorials/Questions & Answers:
Java Web Browser Problem
Java Web Browser Problem  Hello When run my web browser this is not displaying complete page any of the website like other browser.So Plz help me...."); setTitle("NextVision Browser"); setSize(600,400); Container
Java web start problem with jre 1.6 - Java Beginners
Java web start problem with jre 1.6  Hi all, We are using jnlp... in the client side using Java web start. Using three jnlp files we are doing... it with Java Web Start --%>
Advertisements
Applet run with appletviewer but not in browser, any code problem.
Applet run with appletviewer but not in browser, any code problem.  ... the 52 cards will be show in browser as by "appletviewer" and run as "java applet" I... as java applet its working, but not on browser. Please check can I call
Show pdf's in web browser by using jsp?
Show pdf's in web browser by using jsp?  Hi, I want to display pdf file in browser by clicking the link, available in JSP page. When am trying to do this by using Anchor tag with absolute path, it is showing the error as: Http
to run html code in web browser - JSP-Servlet
to run html code in web browser  how to run jsp file which calls html file on web browser??  Hi Friend, Try the following code: 1)form.jsp: Enter Name: 2)welcome.html: Add Profile Edit
how to present the excel to the web browser in jsp
how to present the excel to the web browser in jsp  How to present the content of the newly created excel file in the following jsp to the web browser: <%@ page import="java.io.InputStream" %> <%@ page import
how to display the excel file in the web browser.
how to display the excel file in the web browser.  > %@ page import="java.io.InputStream" > %> <%@ page > import="org.apache.poi.xssf.usermodel.XSSFSheet"%> > <%@ page > import
Browser making by java coding
Browser making by java coding  import javax.swing.*; import...*; import java.io.*; public class Browser extends JFrame implements...[]) { if(args.length==0) new Browser ("http:google.com"#; else new Browser#args#0
browser
in the swing because I am working on my project Browser and one more problem is that when I entered the URL then some page open which made in java and the page
Toolbar to a browser - Java Beginners
to display toolbar on the browser? Thanks  I want to create a website's... browser, some site ask us to download the application and install it. so i wanted
web service problem - WebSevices
web service problem  I have created web service client and server for File transfering using axis2/java.I want to add JAX-RPC client Handler...; Thank u....Actually web service without client handler is working. I want
browser
browser  how to make a browser
opening new browser with new JSESSIONID using java
opening new browser with new JSESSIONID using java  I am facing following problem, I am trying to open a new browser using java. First i have opened one IE browser and manually. And i ran my LaunchURL.java file, it is opening new
Opening a browser only with body from a java program
Opening a browser only with body from a java program  Hi all, I got following requirement, Opening a browser window only with body and title bar... to launch web browser"; public static void openURL(String url) { try
Browser tire - Java Interview Questions
Browser tire  If we use multithreading in my application then which tire is needed on clients browser so that application run successfully? Plz help me ass soon as possible
browser
browser  how to add menu items in the menu in java swing through java coding
Null pointer exceptation-Java Servlet web application,Problem connecting with MYSQL database
Null pointer exceptation-Java Servlet web application,Problem connecting.... T_T I have develop my java web application in window Environment and now i.... T_T I have develop my java web application in window Environment and now i
Cross platform browser question - Java Beginners
-browser (works in Firefox and MS IE) web page using anonymous JS methods...Cross platform browser question  Can you tell me what this is specifially asking for? I have my program that works fine, but the instructor said
Java Swing Open Browser
Java Swing Open Browser Java provides different methods to develop useful... that will open the specified url on the browser using java swing. This example will really... opens the default browser with the specified url. Here is the code: 1
Embed Default Browser within Java Application
Embed Default Browser within Java Application  After some googling i... to embed browser with or without using Netbeans I ve already tried this 2 minutes Browser But i m getting the error in netbeans as : isDefaultBrowserMozilla
opening internet browser in java program - Swing AWT
opening internet browser in java program  i want a code to open the internet browser in swing program using JFrame.  Hi Omkar, Use..." }; String browser = null; for (int count = 0; count <
Problem In applet Its run on browser but hang and blinking when image is draging some where.
Problem In applet Its run on browser but hang and blinking when image is draging some where.  I am Created applet in working properly on browser... browser and come back only gray screen shows, I thing you are understanding
detecting browser time zone - Java Interview Questions
detecting browser time zone  Hi! Is it possible to detect the user browser time zone that means his country. if possible please let me know how to do it... thanks in advance
download a file from browser - Java Beginners
download a file from browser  How to download a file from browser and save it in local path
getting the excel path throuh web browser given from client(i.e thruogh .jsp)
getting the excel path throuh web browser given from client(i.e thruogh .jsp)  1)when client uploads the excel sheet through a .jsp page, 2)get that excel path from web browser and read the data from the excel and printing
Java Enabled browsers
; Java language is the most powerful language and is widely used in the web application. Today most of the web browser are java compatible. Few of them... Vista. Netscape: Netscape Web browser version 8.0(as the first version) was first
java Problem
java Problem  I want to create a binary tree for displaying members in Downline. i am creating a site for MLM(Multi-Level MArketing). tree must be dynamically populated from database. is there any help for me. Thanks in advance
JAVA CLASSPATH PROBLEM
JAVA CLASSPATH PROBLEM  hi all Friends I am stuck using the java servlets and problem raise for classpath. I had a problem with servlet to call... that it didn't found any java class (which is java class calling from servlet). but i
JAVA Problem
JAVA Problem  Write a program that takes two parameters 1. a word 2. an array of words It should then remove all instances of the word in the array. For Example: INPUT word="ravi" word_array = ["Chethan Bhagat
java web application - Ant
java web application  hai, iam new to J2EE. i've installed jdk... tell me the steps to build and deploy a small web application on MyEclipse?(like HelloWorld).Please tell me the directory structure to place my java classes
how can clear the browser cache memory using java script
how can clear the browser cache memory using java script  how can clear the browser cache memory using java script
Advertisements
 

 

 

DMCA.com