Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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
Missing name Mising name is currently offline Missing name Mising name
Messages: 6
Registered: August 2011
Location: India
Junior Member
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
Grant Gayed is currently offline Grant Gayed
Messages: 2148
Registered: July 2009
Senior Member
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
Missing name Mising name is currently offline Missing name Mising name
Messages: 6
Registered: August 2011
Location: India
Junior Member
Thanks a lot..
Previous Topic:Pre-define menu / PartSashContainer
Next Topic:Run ant files from RCP app
Goto Forum:
  


Current Time: Sat Apr 19 11:48:26 EDT 2014

Powered by FUDForum. Page generated in 0.01564 seconds