Web Browser using Java


import java.io.*;
import java.net.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
public class WebBrowser extends JFrame{
String temp,urlQueue[]=new String[20];
int F=0,R=-1;
JButton go=new JButton(“Go”);
JButton prev=new JButton(“Prev”);
JButton next=new JButton(“Next”);
JTextField url=new JTextField(30);
JEditorPane page=new JEditorPane();
public static void main(String args[]){
JFrame obj=new WebBrowser();
obj.setTitle(“Browser”);
obj.setSize(800,500);
obj.setVisible(true);
}
public WebBrowser(){
Components();
Events();
}
public void Components(){
getContentPane().setLayout(null);
url.setBounds(20,400,200,20);
go.setBounds(240,400,20,20);
prev.setBounds(100,440,40,20);
next.setBounds(160,440,40,20);
page.setBounds(10,10,790,375);
getContentPane().add(page);
getContentPane().add(url);
getContentPane().add(go);
getContentPane().add(next);
getContentPane().add(prev);
}
public void Events(){
this.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we){
System.exit(0);
}
}
);
go.addActionListener(new Browser());
prev.addActionListener(new Browser());
next.addActionListener(new Browser());
page.setEditable(false);
page.addHyperlinkListener(new HyperlinkListener()
{
public void hyperlinkUpdate(HyperlinkEvent he){
if(he.getEventType()==HyperlinkEvent.EventType.ACTIVATED)
{
try{
temp= he.getURL().toString();
page.setPage(temp);
R++;
urlQueue[R]=temp;
url.setText(temp);
}
catch(Exception e)
{

}
}
}
}
);
}
public class Browser implements ActionListener{
public void actionPerformed(ActionEvent ae) {
try{

if(ae.getSource()==go){
temp=url.getText();
page.setPage(temp);
R++;
urlQueue[R]=temp;
}
else if(ae.getSource()==prev){
R–;
temp=urlQueue[R];
page.setPage(temp);
}
else if(ae.getSource()==next){
R++;
temp=urlQueue[R];
page.setPage(temp);
}
}
catch(IOException e)
{
}

}
}
}

Advertisements

One thought on “Web Browser using Java

  1. hey there and thank you for your info – I
    have certainly picked up anything new from right here.
    I did however expertise a few technical issues using
    this website, as I experienced to reload the web site a lot of times previous to I could get it to load properly.
    I had been wondering if your web host is OK? Not that I
    am complaining, but slow loading instances times will very frequently
    affect your placement in google and could damage your high quality score if ads and marketing with
    Adwords. Well I am adding this RSS to my email and can look out for
    a lot more of your respective intriguing content.
    Ensure that you update this again soon.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s