java - Relative path in JLabel HTML -


I am trying to show JLable an HTML which refers to the picture using a relative path. But I'm unable to locate the JLable image. When I am using the full path then it works fine.

I have tried to run programs from the command line or from eclipse and I have to add a dialog to show that where the current working directory is but for the benefit I have come to the conclusion that the image is present Not found in directory - which brings me to the point Where is the image seen?

Here is a test code that shows what I'm doing:

  import javax.swing. *; Public class HTMLLabel extends JFrame {public HTMLLabel () {setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); Employmentpan Show Message Dialeg (this, System.GetProperty ("User Guide"); String html = "& lt; html> \ n" + "& lt; body & gt; \ n" + "div style = \" text-align: center; \ "& Gt; \ n" + "IMG src = \" file: //s.png \ "& gt; \ n" + " \ n" + "& lt ; / Body & gt; \ n "+" & lt; / html & gt; "; Jlabel label = new jlabal (hl); (Label); Pack (); SetVisible (true); } Public static zero main (string [] args) {new HTMLLabel (); }}  

To prepare HTML text to display JLabel's image relative to Use this function for a class package.

  public static string ready. ; Maitre M = P. Metchar (HTML); Whereas (m.find ()) {html = html.replace (m.group), "src = '" + relativeClass.getResource (m.group (1)) + "' ');} return HTML;}  

The function changes it to make the content of "source" relative to the provider class.

Example:

  JLabel.setText ( ReadyHtmlToJLabelText (this.getClass), "& lt; html> 
Bla bla bla ... div

However, use JEditorPane for real HTML support.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -