Results 1 to 8 of 8

Thread: WebPage problem

  1. #1
    jsobel is offline Member
    Join Date
    Apr 2012
    Posts
    68
    Rep Power
    0

    Default WebPage problem

    I am trying to view this webpage in a pane but it gives me errors every time i try each time the errors are different
    Java Code:
    import javax.swing.*;
    import java.io.*;
    
    public class test {
    
      public static void main(String[] args) 
      {
         JEditorPane jep = new JEditorPane();
         jep.setEditable(false);   
         try 
         {
           jep.setPage("http://www.google.com");
         }
         catch (IOException e) {e.printStackTrace();} 
         JScrollPane scrollPane = new JScrollPane(jep);     
         JFrame f = new JFrame("webpage");
         f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         f.getContentPane().add(scrollPane);
         f.setSize(512, 342);
         f.show();
      }
    }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: WebPage problem

    it gives me errors
    Can you post the text of some of the errors?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: WebPage problem

    Post the error....and read the API for JEditorPane. If you are using less the JDK7, there is no setPage(String) method (compile time error). If you are using JDK7, you need to pass a valid URL (runtime error). Are you trying to set the text, or read a URL and set the content of the JEditorPane to the content of that URL?

  4. #4
    jsobel is offline Member
    Join Date
    Apr 2012
    Posts
    68
    Rep Power
    0

    Default Re: WebPage problem

    here is the error

    java.net.SocketException: Address family not supported by protocol family: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Du alStackPlainSocketImpl.java:69)
    at java.net.AbstractPlainSocketImpl.doConnect(Abstrac tPlainSocketImpl.java:337)
    at java.net.AbstractPlainSocketImpl.connectToAddress( AbstractPlainSocketImpl.java:198)
    at java.net.AbstractPlainSocketImpl.connect(AbstractP lainSocketImpl.java:180)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.j ava:157)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.j ava:391)
    at java.net.Socket.connect(Socket.java:579)
    at java.net.Socket.connect(Socket.java:528)
    at sun.net.NetworkClient.doConnect(NetworkClient.java :180)
    at sun.net.http://www.http.HttpClient.openServe...ient.java:388)
    at sun.net.http://www.http.HttpClient.openServe...ient.java:483)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java :213)
    at sun.net.www.http.HttpClient.New(HttpClient.java:300)
    at sun.net.www.http.HttpClient.New(HttpClient.java:316)
    at sun.net.http://www.protocol.http.HttpURLConn...tion.java:992)
    at sun.net.http://www.protocol.http.HttpURLConn...tion.java:928)
    at sun.net.http://www.protocol.http.HttpURLConn...tion.java:846)
    at sun.net.http://www.protocol.http.HttpURLConn...ion.java:1296)
    at java.net.HttpURLConnection.getResponseCode(HttpURL Connection.java:468)
    at javax.swing.JEditorPane.getStream(JEditorPane.java :736)
    at javax.swing.JEditorPane.setPage(JEditorPane.java:4 35)
    at javax.swing.JEditorPane.setPage(JEditorPane.java:8 83)
    at test.main(test.java:12)

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: WebPage problem

    The code works for me using:
    D:\Java\jdk1.6.0_29\bin\javac.exe
    D:\Java\jdk1.6.0_29\bin\java.exe
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: WebPage problem

    Java Code:
    "<a class="linkification-ext" href="http://www.google.com" title="Linkification: h...."
    is not a valid URL (or a valid string to compile). Pass an appropriate URL, and perhaps describe what exactly your goals are. Your call is the same as calling:

    URL url = new URL("<a class="linkification-ext" href="http://www.google.com" title="Linkification: h...");
    URLConnection conn = url.openConnection();

    which a) won't compile and b) will throw an exception (however I'd expect it to be a MalformedURLException).

  7. #7
    jsobel is offline Member
    Join Date
    Apr 2012
    Posts
    68
    Rep Power
    0

    Default Re: WebPage problem

    it worked one time and then stopped working

  8. #8
    kammce's Avatar
    kammce is offline Senior Member
    Join Date
    Dec 2010
    Location
    California
    Posts
    194
    Rep Power
    4

    Default Re: WebPage problem

    Quote Originally Posted by jsobel View Post
    it worked one time and then stopped working
    So... you changed the code and it stopped working or the unchanged program stopped working? maybe a network problem? My suggestion, is to write a catch(SocketException), and see what happens after using your program.
    My API:
    Java Code:
    cat > a.out || cat > main.class

Similar Threads

  1. loading webpage
    By juhiswt in forum New To Java
    Replies: 0
    Last Post: 03-17-2011, 07:37 PM
  2. Serving up a Webpage
    By kammce in forum Networking
    Replies: 7
    Last Post: 01-01-2011, 03:57 AM
  3. Add a Swing UI in a WebPage
    By ivvgangadhar in forum AWT / Swing
    Replies: 9
    Last Post: 06-30-2009, 09:16 AM
  4. save a webpage.....?
    By 05bit044 in forum Networking
    Replies: 1
    Last Post: 08-04-2008, 05:49 PM
  5. Replies: 3
    Last Post: 10-31-2007, 12:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •