Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-06-2008, 09:36 PM
Member
 
Join Date: Jul 2008
Posts: 1
jeff666 is on a distinguished road
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
Sponsored Links
  #2 (permalink)  
Old 07-06-2008, 10:03 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Norm is on a distinguished road
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 10:05 PM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


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

vB 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
Need Help! swt/Browser sealyu SWT / JFace 4 07-09-2008 10:16 PM
Browser Jessie Madman AWT / Swing 19 06-11-2008 02:00 PM
how to get url from browser srinivas reddy New To Java 0 02-08-2008 09:46 AM
Google Maps API mew New To Java 0 12-26-2007 12:28 PM
Google Singleton Detector 0.7.2 levent Java Announcements 0 07-26-2007 10:12 PM


All times are GMT +3. The time now is 03:22 PM.


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