Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Images Display in SWT Browser using in memory text
Images Display in SWT Browser using in memory text [message #905424] Thu, 30 August 2012 07:07 Go to next message
Eclipse UserFriend
Hi,

I am using org.eclipse.swt.browser.Browser in my code.I have created the html text and and i passing this html content to browser using setText method. My html has one image which is available in other plugin jar file. But this images does not get displayed in Browser. As suggested in eclipse forum i have tried to use <base href="#"> in code but it is not working. My code is as below:-


public static void main(String[] args) {
/* Relative links: use the HTML base tag */
String html = "<html><head>"
+ "<title>HTML Test</title></head>"
+ "<body><p><img src=\"jar:file:/d:/inst/testplugin.jar/mytest/images/file12.png\">"
+ "</p><br/><br/>"
+ "<A NAME=\"link\">This is the target<A/></body></html>";

Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
Browser browser = new Browser(shell, SWT.NONE);
browser.setText(html);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}


I am not getting what is wrong. But somehow browser is not getting this file.
Please suggest me how can i resolve this issue?

Thanks,
Pinky
Re: Images Display in SWT Browser using in memory text [message #906102 is a reply to message #905424] Fri, 31 August 2012 12:11 Go to previous messageGo to next message
Eclipse UserFriend
The underlying renderers will not retrieve a resource contained within a
jar. Your file12.png has to be on your local file system somewhere,
which will allow you to point at it with a simple file:///... url.

Grant


On 8/30/2012 7:07 AM, Missing name Mising name wrote:
> Hi,
>
> I am using org.eclipse.swt.browser.Browser in my code.I have created the
> html text and and i passing this html content to browser using setText
> method. My html has one image which is available in other plugin jar
> file. But this images does not get displayed in Browser. As suggested in
> eclipse forum i have tried to use <base href="#"> in code but it is not
> working. My code is as below:-
>
> public static void main(String[] args) {
> /* Relative links: use the HTML base tag */
> String html = "<html><head>"
> + "<title>HTML Test</title></head>"
> + "<body><p><img
> src=\"jar:file:/d:/inst/testplugin.jar/mytest/images/file12.png\">"
> + "</p><br/><br/>"
> + "<A NAME=\"link\">This is the target<A/></body></html>";
>
> Display display = new Display();
> Shell shell = new Shell(display);
> shell.setLayout(new FillLayout());
> Browser browser = new Browser(shell, SWT.NONE);
> browser.setText(html);
> shell.open();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
> display.dispose();
> }
>
>
> I am not getting what is wrong. But somehow browser is not getting this
> file.
> Please suggest me how can i resolve this issue?
>
> Thanks,
> Pinky
Re: Images Display in SWT Browser using in memory text [message #907007 is a reply to message #906102] Mon, 03 September 2012 02:16 Go to previous message
Eclipse UserFriend
Thanks a lot..
Previous Topic:Pre-define menu / PartSashContainer
Next Topic:Run ant files from RCP app
Goto Forum:
  


Current Time: Tue Jul 15 03:38:03 EDT 2025

Powered by FUDForum. Page generated in 0.06413 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top