Skip to main content


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 11:07 Go to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
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 16:11 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
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 06:16 Go to previous message
Missing name Mising name is currently offline Missing name Mising nameFriend
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: Fri Apr 26 19:06:08 GMT 2024

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

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

Back to the top