Java Browser source code
#1

Code:
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
public class browser extends JFrame implements HyperlinkListener,ActionListener
{
  public static void main(String args[])
  {
    if(args.length==0)
     new browser("file:\\e:text.html");
    else
     new browser(args[0]);
     }
     private JButton home;
     private JTextField urlfield;
     private JEditorPane htmlpane;
     private String initialurl;

     addWindowListener(new ExitListener());
     WindowUtilities.setNativeLookAndFeel();

     JPanel topPanel = new JPanel();
     topPanel.setBackground(color.lightGray);
     home = new JButton("click");
     urlfield=new JTextField(30);
     urlfield.setText(intialurl);

     home.addActionListener(this);
     urlfield.addActionListener(this);

     JLabel urllabel=new JLabel("url");
     topPanel.add(home);
     topPanel.add(urlfield);

     getContentPane().add(topPanel,Borderlayout.NORTH);
      try  
       {
        htmlpane = new JEditorPane(initialurl);
        htmlpane.setEditable(false);

        htmlpane.addHyperlinkListener(this);
        JScrollPane scrollpane=new JScrollPane(htmlpane);
        getContentPane().add(htmlpanel.Borderlayout.CENTER);
          }
       catch(IOException e)
        {
         warnuser("can't build htmlpane for" + initialurl + ":"+ e);
          }

          Dimension Screensize=getToolkit().getScreensize();
          int width=screensize.width*8/10;
          int height=screensize.height*8/100;

          setBounds(width/8,height/8,width,height);
          setVisible(true);
          public void actionPerformed(ActionEvent ae)
           {
             String url;
             if(ae.getSource()==urlfield)
               url=urlfield.getText();
             else
               url=initialurl;

            try
            {
              htmlpane.setPage(new URL(url));
              urlfield.setText(url);
               }

           catch(IOException e)
           {
            warnuser("cant't build htmlpane for" +initialurl + ":" + e);
              }

           public void hyperlink update(HyperlinkEvent event)
            {
             if(event.getEventType()==Hyperlink.EventType.ACTIVATED)
              {
               try
               {
                htmlpane.setPage(event.getURL());
                urlfield.setText(event.getURL();
                 }

              catch(IOException e)
              {
               warnuser("cant't build htmlpane for" +initialurl+ ":" + e);
                }

               public class ExitListener extends WindowAdapter
               {
                public void WindowClosing(WindowEvent e)
                 {                                                                        
                   System.exit(0);
                   }
                 }  

               private void warnuser(String msg)
               {
                JOptionpane.showMessageDialog(this,msg,"error",JOptionPane.Error_Message);
                 class WindowUtilities
                 {
                  public static void setNativeLookAndFeel()
                   {

                    try
                    {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeel class native());
                      }

                    catch(Exception e)
                    {
                      }
                     }
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: artificial intellience browser using java speech api, truthfinder java source code, linux source code browser, java abstractlist source code, stegomagic source code in java, rectangle java source code, source code java outlier,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Possibly Related Threads...
Thread Author Replies Views Last Post
  projects in core java project topics 6 16,128 16-01-2018, 11:15 AM
Last Post: dhanabhagya
  Steganography implemented in Java science projects buddy 14 12,187 24-05-2016, 10:15 AM
Last Post: dhanabhagya
  STUDENT INFORMATION SYSTEM IN JAVA project topics 14 10,624 19-08-2015, 11:28 PM
Last Post: Guest
  mini projects in java project topics 7 18,789 01-05-2015, 04:18 PM
Last Post: seminar report asees
  Visa Processing System full report and asp source code project topics 2 5,538 19-06-2014, 06:54 PM
Last Post: seminar report asees
  distributed cache updating for the dynamic source routing protocol project report tiger 4 3,000 05-03-2013, 02:22 PM
Last Post: Guest
  application projects in java and vb.net (titles and topics) project topics 1 5,497 28-11-2012, 01:11 PM
Last Post: seminar details
  Energy-Efficient Routing in Mobile Ad Hoc Networks: Mobility-Assisted Case (Java) project topics 1 1,756 12-11-2012, 12:42 PM
Last Post: seminar details
  Net Auction java based project report project topics 2 3,700 01-11-2012, 12:59 PM
Last Post: seminar details
  distributed applications using RMI-Java model. seminar class 1 1,478 31-05-2012, 12:29 AM
Last Post: Guest

Forum Jump: