Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-06-2008, 07:36 PM
Member
 
Join Date: Jul 2008
Posts: 1
Rep Power: 0
jeff666 is on a distinguished road
Default google in web browser
HI

Can anyone help i have created this web browser (code underneath), but i cant get google results up. Does anyone have any sujestions.

import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import javax.swing.*;
import javax.swing.event.*;

public class ReadServerFile extends JFrame {
private JTextField enter;
private JEditorPane contents;

public ReadServerFile()
{
super( "Jeff's Browser" );

Container c = getContentPane();

enter = new JTextField( "Enter file URL here" );
enter.addActionListener(
new ActionListener() {
public void actionPerformed( ActionEvent e )
{
getThePage( e.getActionCommand() );
}
}
);
c.add( enter, BorderLayout.NORTH );

contents = new JEditorPane();
contents.setEditable( false );
contents.addHyperlinkListener(
new HyperlinkListener() {
public void hyperlinkUpdate( HyperlinkEvent e )
{
if ( e.getEventType() ==
HyperlinkEvent.EventType.ACTIVATED )
getThePage( e.getURL().toString() );
}
}
);
c.add( new JScrollPane( contents ),
BorderLayout.CENTER );

setSize( 400, 300 );
show();
}

private void getThePage( String location )
{
setCursor( Cursor.getPredefinedCursor(
Cursor.WAIT_CURSOR ) );

try {
contents.setPage( location );
enter.setText( location );
}
catch ( IOException io ) {
JOptionPane.showMessageDialog( this,
"Error retrieving specified URL",
"Bad URL",
JOptionPane.ERROR_MESSAGE );
}

setCursor( Cursor.getPredefinedCursor(
Cursor.DEFAULT_CURSOR ) );
}

public static void main( String args[] )
{
ReadServerFile app = new ReadServerFile();

app.addWindowListener(
new WindowAdapter() {
public void windowClosing( WindowEvent e )
{
System.exit( 0 );
}
}
);
}
}


Thanx Jeff
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 07-06-2008, 08:03 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Rep Power: 4
Norm is on a distinguished road
Default
To help debug, we need to see what the data was. Add a println("loc=" + location) statement to show the value being looked up. Also your error message could show the bad URL!
Then copy the output from the program and paste it here.

Do you know the format for a valid URL?
protocol hostname portnumber filename reference (without the spaces)

Last edited by Norm; 07-06-2008 at 08:05 PM.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Browser Jessie Madman AWT / Swing 20 02-17-2009 01:56 PM
Need Help! swt/Browser sealyu SWT / JFace 4 07-09-2008 08:16 PM
how to get url from browser srinivas reddy New To Java 0 02-08-2008 07:46 AM
Google Maps API mew New To Java 0 12-26-2007 10:28 AM
Google Singleton Detector 0.7.2 levent Java Announcements 0 07-26-2007 08:12 PM


All times are GMT +2. The time now is 12:50 PM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org