Java Web Browser Problem

Ads
 

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.

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;
    }
}
View Answers

Ads









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
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
Advertisements
ModuleNotFoundError: No module named 'eilat-web-browser'
ModuleNotFoundError: No module named 'eilat-web-browser'  Hi, My... named 'eilat-web-browser' How to remove the ModuleNotFoundError: No module named 'eilat-web-browser' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'eilat-web-browser'
ModuleNotFoundError: No module named 'eilat-web-browser'  Hi, My... named 'eilat-web-browser' How to remove the ModuleNotFoundError: No module named 'eilat-web-browser' error? Thanks   Hi, In your
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
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
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 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
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
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
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
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
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
resolution problem in java
resolution problem in java  I designed project in java in my PC when run the same project in some other PC i can't fully view my java forms.Some said that it is resolution problem
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
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
Problem in uploading java application
Problem in uploading java application  I have uploaded my java application (folder created under webapps) using Filezilla FtpClient.Application... this problem
how to get browser cookies in java
how to get browser cookies in java  Hi, How to get cookies in serverlet and then print? how to get browser cookies in java? Thanks   Hi, Use following code: Cookie[] cookies = request.getCookies(); for (int i = 0
for a problem in coading - Java Beginners
for a problem in coading  what is the problm in following coading...(String[] args) { mywindow (); } }   Hi Friend, There is no problem... mywindows.java Run : java mywindows Thanks RoseIndia Team
java problem - Java Beginners
java problem  Write a program that could be used to help children...(); System.out.print("How many problems would you like? "); double q = scan.nextDouble(); System.out.println(); double r=0,w=0; for (int idx = 1; idx <= q
java sms problem
java sms problem  i am developing web site in which i have to maintain sms system where one can message his/her detail and it should be stored in the database.please give me some idea how to maintain it as i am beginner.Thank you
Problem on JAVA Programme
Problem on JAVA Programme  public class AA { int add(int i) { int y = i; y += 20; if (y <= 100){ y +=30;add(y);} System.out.println("Final Value of y : " + y); return y; } public static void main
Java implementation problem
/answers/viewqa/Java-Beginners/28578-java-implementation-problem-.html...Java implementation problem  I want to implement following in java... problem in your post previews. please consider 1. 2. points just after main
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
java implementation problem
java implementation problem   I want to implement following in java code : Main thread Create three threads wait for completion of stage 2 of all three threads Access all three local variable (LC0, LC1, LC2) of threads bulid
Basic problem for Java experts
Basic problem for Java experts  This assignment will test your knowledge of Arrays Array searching Array sorting Array processing Specification An athletics club require a simple statistical analysis program for analysing lap
browser
browser  how to make a browser
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
Java program problem
Java program problem  Hi, I took the chance to login here in your educational page due to my questions in mind about my java programming assignment... is a path to a directory. Example: java DuplicateFinder c:\Documents
java array problem
java array problem  suppose i have an array a[] at a[0] i have value 5,7 the thing is that i want to assign the value of array a[0]=5,7 to two variable let it be j,k that is j=5 and k=7 plz help regards
Java I/O problem
Java I/O problem   Write a Java application that prompts the user to input their Name, Address, Date of Birth and Student ID number using the standard input - this information should then be saved to a file named studentData

Ads