answersLogoWhite

0

You want to get source code of web browser in java?

Updated: 8/17/2019
User Avatar

Wiki User

11y ago

Best Answer

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import java.net.*;

import java.io.*;

public class Browser

{

private JFrame frame;

private JPanel panelTop;

private JEditorPane editor;

private JScrollPane scroll;

private JTextField field;

private JButton button;

private JButton button1;

private URL url;

public Browser(String title)

{

initComponents();


//set the title of the frame

frame.setTitle(title);


//set the default cloe op of the jframe

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


//set size of frame

frame.setSize(1370,700);


//add jpanel to north of jframe

frame.add(BorderLayout.NORTH, panelTop);


//add textfield and navigation button to jpanel.

panelTop.add(field);

panelTop.add(button);

//panelTop.add(button1);

// panelTop.add(button);


//add scroll pane to jframe center

frame.add(BorderLayout.CENTER, scroll);


//set the frame visible

frame.setVisible(true);

}//end Browser() constructor


private void initComponents()

{

//create the JFrame

frame = new JFrame();


//create the JPanel used to hold the text field and button.

panelTop = new JPanel();

//set the url

try

{

url = new URL("http://www.mr-jatt.com");

}

catch(MalformedURLException mue)

{

JOptionPane.showMessageDialog(null,mue);

}

//create the JEditorPane

try

{

editor = new JEditorPane(url);

//set the editor pane to false.

editor.setEditable(false);

}

catch(IOException ioe)

{

JOptionPane.showMessageDialog(null,ioe);

}

//create the scroll pane and add the JEditorPane to it.

scroll = new JScrollPane(editor, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,

JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);


//create the JTextField

field = new JTextField();


//set the JTextField text to the url.

//we're not doing this on the event dispatch thread, so we need to use

//SwingUtilities.

SwingUtilities.invokeLater(new Runnable()

{

public void run()

{

field.setText(url.toString());

}

});


//create the button for chanign pages.

button = new JButton("Go");

//add action listener to the button

button.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

try

{

editor.setPage(field.getText());

}

catch(IOException ioe) {

JOptionPane.showMessageDialog(null, ioe);

}

}

});

//button=new JButton("back");

}//end initComponents()


public static void main(String[] args)

{

SwingUtilities.invokeLater(new Runnable()

{

public void run()

{

new Browser("Simple web browser");

}

});

}//end main method.

}//end Browser class

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: You want to get source code of web browser in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

It is not an error not to end a Java file name with the java extension?

If you want to compile a java program the name of that source code must end with extension .java


What is the name of the plugin for Minecraft?

If you want to play Minecraft in your web browser, you will have to install Java on your computer. Java usually comes with browser plugins that can be used to run Java apps such as Minecraft in your browser. You can download Java from Java's website.


What is java file in java?

A java file contains the code you write. One java file contains one class so for example when I want to make a class called Person, the source code is saved in Person.java


Is the JRE platform dependent?

True. Java source code is called "platform independent" because it runs on top of the Java Runtime Environment (JRE). In order for this to work, a special JRE must be created for the platform you want to run a Java program on.


Where do you go to download java script?

You need not download javascript. Any machine where you have a web browser like Internet Explorer or Mozilla would have javascript inbuilt in them. If you view the source (Right click-> View Source : and you can even try on this page itself), you will see tags such as <script type="text/javascript"> These is the embedded javascript code. If you have a source too in the script tag, simply locate the address and type it out in your browser, you will have the entire javascript file.


How do you install code in the browser?

Some web browsers will allow code insertion and some will not. The ability to insert code depends on what browser you have and why you want to insert code into it.


If i want to play rs its says you don't have java but i have and i turn it on how can i fix it?

Try a different browser. For example, if it doesn't work with FireFox, try Opera or Google Chrome. You may also want to try reinstalling your browser, or downloading Java.Try a different browser. For example, if it doesn't work with FireFox, try Opera or Google Chrome. You may also want to try reinstalling your browser, or downloading Java.Try a different browser. For example, if it doesn't work with FireFox, try Opera or Google Chrome. You may also want to try reinstalling your browser, or downloading Java.Try a different browser. For example, if it doesn't work with FireFox, try Opera or Google Chrome. You may also want to try reinstalling your browser, or downloading Java.


How do you get a java compatible web browser?

Most browsers nowaday are compatible with Java. In some cases you need to install Java as a plug-in. In this case, the browser will usually ask you automatically, whether you want to install Java, as soon as it is needed - i.e., as soon as you access a Web page that requires Java support.


Where can l flnd a HTML source for mlcrosoft's 404 code the offlclal one that says page not found because l want to recreate that page as a prank.?

Just find your way to that page, then click the view button in your browser, the source, or page source. All of that is the HTML code for that page.


Major difference between java and cpp?

CPP typically stands for the C PreProcessor, which does macro expansion on C source code. What I suspect you want to know are the differences between C++ and Java. See the links below for more information on that topic.


Want a bank ATM code in java?

maa chuda apni saale


Why is compiling necessary?

Compilers are only necessary for programmers; ordinary users do not require them. A compiler is a program which converts a high-level source input into a lower-level source output, reducing the amount of abstraction. In most cases the output is native machine code and/or an assembly source, however there are some exceptions, such as the Java compiler which outputs Java byte code, and cross-language compilers such as C++ to C compilers. Machine's do not understand either high-level source code or low-level assembly code, they only understand their own native machine code. Thus conversion to machine code is necessary. Once converted to machine code, no further translation is necessary. Assembly sources must be converted using an assembler, however assembly is a machine-dependent language (it is non-portable). High-level languages are generally portable and are either compiled or interpreted. Interpretation requires a runtime program to perform the conversion while the source code is executing and performs poorly compared to a native machine code program. Java is both compiled and interpreted. That is; Java source code compiles to Java byte code which is suitable for interpretation by the Java virtual machine. It is not possible to compile a low-level source to produce a high-level output. For example, you cannot convert C to C++ using a compiler, just as you cannot convert assembly language to C. Compilers can only reduce the amount of abstraction in the source code, not increase it. If you want to add more abstraction, you need to do so manually.