i m developing a new web browser as my project in java.I have done the initial coding but when i run google homepage on my simple web browser,it shows me some html code to get rid of this code?.i have also attach the view of this problem,plz look at it.

Recommended Answers

All 13 Replies

.how to get rid of this code?

The font of your image is too small, can you copy and paste here what you want us to see?

How can we recommend a change to your code if you don't show it?
Obviously your parser and formatter is not working properly.

following is my code

package javabrowser;

 * @author Administrator
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.html.*;
 * @author Administrator
public class JavaBrowser extends JFrame 
private JTextField takeURL;
JButton start;
public JEditorPane browserData;
JScrollPane Scroll;
JPanel p,p2;
URL getData;
JFrame frame;

     * @param args the command line arguments

    public JavaBrowser()
                setTitle("Java Browser");
               Container pane=getContentPane();

               takeURL =new JTextField();
                start=new JButton("Start");
                browserData=new JEditorPane();
                browserData.addHyperlinkListener(new LinkActivator() );

                Scroll=new JScrollPane(browserData);
                Scroll.setPreferredSize(new Dimension(503,503));
                p=new JPanel();

                takeURL.setSize(500, 20) ;
                start.setLocation(510,10 );
                start.setSize(80, 20) ;
              start.addActionListener(new ActionListener(){
                  public void actionPerformed(ActionEvent e) 
                     String string_of_url=new String(takeURL.getText()); 
                  }} );
                browserData.setSize(500, 500) ;
                p.setSize(508,508) ;
                catch(Exception e)
    class LinkActivator implements HyperlinkListener {
    public void hyperlinkUpdate(HyperlinkEvent he) {
      HyperlinkEvent.EventType type = he.getEventType();
      if (type == HyperlinkEvent.EventType.ACTIVATED)
      catch(Exception ie)
    public void getData(String string_of_url)
          URL oracle = new URL(string_of_url+ "/");
        catch(Exception e)

    public static void main(String[] args) {
        // TODO code application logic here
        JavaBrowser jb=new JavaBrowser();

java can't read Javascripts. The code that is showing you the program is a javascript.

so how to get rid of this code,what i should do now?

how to get rid of this code

Read the text of the page and remove the parts that your display engine doesn't know how to format before giving it the text.

Please edit your code and wrap it in code tags. See [code] icon above input box.

how can i rendered javascript code into my simple browser?

Find a package to do the rendering. But, I doubt there is one.

the best way to do a web browser is using another language instead of Java. It would be a whole project to execute javascripts.

using another language instead of Java

@teo 236 Can you explain what the problem is with doing it in Java?

it will be very confusing trying to execute javascripts in java. maybe there is a better language for this kind of projects. If hamzamuradkhanh wants to execute javascripts with java, it's possible but would probably be very slow execution. I researched and found this page if you are interested.

Did you notice this in the rhino doc: written entirely in Java

have you tried to use it? it's confusing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.