Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #1533 > unrolled thread

java.net.ConnectException

Started by"Srik" <srik@THRWHITE.remove-dii-this>
First post2011-04-27 15:33 +0000
Last post2011-04-27 15:33 +0000
Articles 3 — 2 participants

Back to article view | Back to comp.lang.java.gui


Contents

  java.net.ConnectException "Srik" <srik@THRWHITE.remove-dii-this> - 2011-04-27 15:33 +0000
    Re: java.net.ConnectExcep "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:33 +0000
      Re: java.net.ConnectExcep "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:33 +0000

#1533 — java.net.ConnectException

From"Srik" <srik@THRWHITE.remove-dii-this>
Date2011-04-27 15:33 +0000
Subjectjava.net.ConnectException
Message-ID<1177502594.380781.33900@n15g2000prd.googlegroups.com>
  To: comp.lang.java.gui
When i run the following code, i get -  java.net.ConnectException:
Connection refused

import java.net.URL;

import javax.swing.JDialog;
import javax.swing.JEditorPane;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLFrameHyperlinkEvent;

public class EditorPaneTest {

	EditorPaneTest()
	{
		JEditorPane edit = new JEditorPane();
		String str = "<html><body><A        href=http://
www.google.co.in>Googly</A></body></html>";
		edit.setContentType("text/html");
		edit.setText(str);
		edit.setEditable(false);
		edit.addHyperlinkListener(new Hyperactive());
		JDialog disalog = new JDialog();
		disalog.getContentPane().add(edit);
		disalog.show();
	}
	public static void main(String args[])
	{
		new EditorPaneTest();
	}
	class Hyperactive implements HyperlinkListener {

        public void hyperlinkUpdate(HyperlinkEvent e) {
        	System.out.println("hyper link update");
	          if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
{
		      JEditorPane pane = (JEditorPane) e.getSource();
		      if (e instanceof HTMLFrameHyperlinkEvent) {
		          HTMLFrameHyperlinkEvent  evt = (HTMLFrameHyperlinkEvent)e;
		          HTMLDocument doc = (HTMLDocument)pane.getDocument();
		          doc.processHTMLFrameHyperlinkEvent(evt);
		      } else {
		          try {
			      pane.setPage(e.getURL().getHost());
		          } catch (Throwable t) {
			      t.printStackTrace();
		          }
		      }
	          }
	      }
    }
}

I dont know if i have to configure anything or start any service. I am
running this from Eclipse in Linux platform. Can anyone please explain
what i need to do?

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [next] | [standalone]


#1534 — Re: java.net.ConnectExcep

From"Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this>
Date2011-04-27 15:33 +0000
SubjectRe: java.net.ConnectExcep
Message-ID<713b8b9fea30b@uwe>
In reply to#1533
  To: comp.lang.java.gui
Srik wrote:
>When i run the following code, i get -  java.net.ConnectException:
>Connection refused

Do you?  I get different results.  I get
java.net.MalformedURLException: no protocol: www.google.co.in

Which is largely due to this..

..
>        public void hyperlinkUpdate(HyperlinkEvent e) {
>        	System.out.println("hyper link update");
..
>		      } else {
>		          try {
>			      pane.setPage(e.getURL().getHost());

That line should be ..
     pane.setPage(e.getURL());

By the way.  Please..
- Don't include 'tab' characters in source posted to usenet.
- Always capitalise the word 'I'.

Another couple of points are that 
  disalog.show();
.has been deprecated.  Try instead..
  disalog.setVisible(true);

You might try setting the JEditorPane into a JPanel
and calling setPreferredSize() on the JPanel, so the 
GUI does not become compacted down to a title bar.

You should call pack() or validate() before setting the 
GUI visible.

HTH

-- 
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-gui/200704/1

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#1535 — Re: java.net.ConnectExcep

From"Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this>
Date2011-04-27 15:33 +0000
SubjectRe: java.net.ConnectExcep
Message-ID<713b8ff5c0d7b@uwe>
In reply to#1534
  To: comp.lang.java.gui
Andrew Thompson wrote:
..
>Another couple of points are that 
..

Oh, and JEditorPane is entirely unsuited to displaying
web pages that are not directly controlled and carefully 
optimised by you,  to account for the limitations of this
component.

-- 
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-gui/200704/1

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.gui


csiph-web