Link to home
Start Free TrialLog in
Avatar of ivanthepro
ivanthepro

asked on

JSwing - JTable

I went to Java Web Start 1.2, to take a look at the swing set demo. There you can see an example on JTables. It displays a custom table which excepts an ImageIcon.
I looked at its source code and it says this:

ImageIcon strawberry = createImageIcon(...);
...
...
...
Objects[][] data = {{.........,strawberry},{...}}

from the api there is no such method as createImageIcon(...). So I presume its extended from the demomodule, can anyone tell me how this method is written? I tried to use all methods like setting the ImageObserver etc but none seems to match to the example in this swingset

Anyone can help pls?

TIA

Ivan
Avatar of skyshadow
skyshadow

hm i guess that line can be replaced by :

ImageIcon strawberry = new ImageIcon("filename");

:)
-=[sKySh@DoW]=-
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
is there anything wrong with my codes? i've never used swingsets before .. i'm a newbie .. hehehe ..

objects:
from your codes .. it seems like it's a method that returns an imageicon ..

ImageIcon strawberry = new ImageIcon("filename");
----------------------------------------------------------
String path = "/resources/images/" + filename;
        return new ImageIcon(getClass().getResource(path), description);


don't they end up doing the same thing?

:)
-=[sKySh@DoW]=-
Similiar though a bit different how they locate file.
Your code loads the image from a file directly.
The SwingSet code loads it from a URL, plus the named image needs to be accessible by the classloader.

(Plus you're doesn't set the description).
objects:
thks for that ..
by the way .. i was too lazy to type the description part .. hheeeehhee
thks

:)
-=[sKySh@DoW]=-
Avatar of ivanthepro

ASKER

i tried all of your methods, but it seems like the JTable only displays the url instead of the pic?
sorry, my mistake...

okok you are correct