Image not drawn for a JComponent

Hi
I've got a JComponent which I use as a TableCellRenderer.
The problem is that the Image is not drawn to the Graphics object of the paint method. Only when the form is resized is the Image shown. If the image change it is not shown at all. (remove //loadPicture((String)value); in the getTableCellRendererComponent method of the TestCellRenderer class)
I've used other methods on the JComponent just to see if it is working... all the other methods works fine... like the drawLine, drawString ...... but not the drawImage.
Any ideas ?
Here is the code
CODE
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import javax.swing.table.*;
public class TestCellRenderer extends JComponent implements TableCellRenderer{
Image img;
ChangeListener cl;
public TestCellRenderer(){
try{
loadPicture("ac1.gif");
setSize(new Dimension(100,100));
this.setPreferredSize(new Dimension(100,100));
this.setBorder(new LineBorder(Color.RED));
catch(Exception e){
e.printStackTrace();
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column){
//loadPicture((String)value);
this.updateUI();
return this;
public Image getImage(){
return img;
public void setImage(Image img){
this.img = img;
public void addChangeListener(ChangeListener l){
cl = l;
private void loadPicture(String path){
try{
//if (img != null){
// img.flush();
// img = null;
img = Toolkit.getDefaultToolkit().createImage(path);
if (cl != null){
cl.stateChanged(new ChangeEvent(this));
catch(Exception e){
e.printStackTrace();
public void paint(Graphics graphics){
Graphics2D g = (Graphics2D)graphics;
try{
g.drawLine(0,0,getWidth(),getHeight());
g.drawImage(img,0,0,getWidth(),getHeight(),null);
g.setColor(Color.RED);
g.drawLine(getWidth(),0,0,getHeight());
super.paint(g);
catch(Exception e){
e.printStackTrace();
CODE
import javax.swing.table.*;
public class TestModel extends DefaultTableModel{
public TestModel(){
this.addColumn("Image Column");
this.addColumn("Column Two");
CODE
import java.awt.*;
import java.util.*;
import javax.swing.event.*;
import javax.swing.table.*;
import javax.swing.*;
class TestPaintInTable extends JFrame{
private static TestCellRenderer viewer = new TestCellRenderer();
public static void main (String args[]){
TestPaintInTable frame = new TestPaintInTable();
frame.setSize(300,300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
TestModel model = new TestModel();
//Data
Vector vecData = new Vector();
vecData.add("ac.gif");
vecData.add("Aircraft One");
model.addRow(vecData);
vecData.removeAllElements();
vecData.add("ac1.gif");
vecData.add("Aircraft Two");
model.addRow(vecData);
TestTable testTable = new TestTable(model);
TableColumn col = testTable.getColumnModel().getColumn(0);
TestCellRenderer tCR = new TestCellRenderer();
tCR.addChangeListener(new ChangeListener(){
public void stateChanged(ChangeEvent e){
System.out.println("State has changed. Image = " + ((TestCellRenderer)e.getSource()).getImage() );
viewer.setImage(((TestCellRenderer)e.getSource()).getImage());
viewer.update(viewer.getGraphics());
col.setCellRenderer(tCR);
JScrollPane scr = new JScrollPane(testTable);
frame.setLayout(new BorderLayout());
frame.getContentPane().add(viewer,BorderLayout.NORTH);
frame.getContentPane().add(scr,BorderLayout.CENTER);
frame.setVisible(true);
CODE
import javax.swing.*;
import javax.swing.table.*;
public class TestTable extends JTable{
public TestTable(DefaultTableModel model){
super(model);

change this line
g.drawImage(img,0,0,getWidth(),getHeight(),null);
to this
g.drawImage(img,0,0,getWidth(),getHeight(),this);
for the images in the cells, try this link
http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=2&t=000610

Similar Messages

  • OS4 background image not available for iPhone 3G??

    Hey everyone, just installed iOS4 and it deleted all my contacts :((((
    but I can't see how to use a background pic for the standard screen, like it was featured in the keynote video...is this feature not available for us lesser iPhone 3G users???

    {quote:title=gdgmacguy wrote:}Has absolutely nothing to do with marketing policy, rather the particular hardware capability of the phone.{quote}
    that is absolute bs. iPhone 3g can support it fine. Apple just doesn't want to give its 'old' customers any eyecandy, or rather, apple doesn't want to give anyone anything they ask for. Seriously, how long will it take so we can change the text bubbles from aweful silver and baby poop green?

  • Recolor Image not working for multiple images

    I applied themeing and created a Themeing file under Style Lib -> en-us->Themable->spriteTheming.css
    spriteTheming.css is for recoloring image but it is only recoloring spcommon and none other files.
    spriteTheming.css looks like below:
    /* [RecolorImage(themeColor:"ContentAccent7",method:"Tinting")] */
    background-image: url("/_layouts/15/images/spcommon.png?rev=23");
    /* [RecolorImage(themeColor:"ContentAccent7",method:"Tinting")] */
    background-image: url("/_layouts/15/1033/images/spstd2.gif");
    /* [RecolorImage(themeColor:"ContentAccent7",method:"Tinting")] */
    background-image: url("/_layouts/15/images/SharePointFoundation16.png?rev=23");
    /* [RecolorImage(themeColor:"ContentAccent4",method:"Tinting")] */
    background-image: url("/_layouts/15/1033/images/formatmap32x32.png?rev=23");
    this only changes the color of spcommon.png but none of the other images gets the tint, anything I am doing wrong in this file?
    I published it, changed the look but still it does not change anyting.
    It creates the file here:
    _catalogs/theme/Themed/
    but does not display on browser
    I refer to this spriteTheming.css in master page as
    <!--MS:<SharePoint:CssRegistration Name="/Style Library/en-us/Themable/spriteTheming.css" EnableCssTheming="true" After="corev15.css" runat="server">-->
    <!--ME:</SharePoint:CssRegistration>-->
    Any help is appreciated....

    Thoughts?

  • Images not opening for edits in Photoshop from Lightroom all software is updated

    I am working on  a MacBook Pro and today after making basic edits in Lightroom 5.+ the images won't then open in Photoshop to edit there.
    Any help would be appreciated
    Charles

    Geoff, I am using the very latest CC version of Lightroom 5.7 and Photoshop v 2014.2.2 running in 64bit mode, on a MacBook Pro with Mountain Lion OS 10.8.5. I used it yesterday morning and things worked fine but in the afternoon, I created a new catalog for a project I was working on. The first image everything worked as normal. I mad some basic White Balance corrections, along with contrast adjustments then take the images into Photoshop to remove the backgrounds but going to the menu item Edit in Photosho. If photoshop is down, it opens the software but the images don't transfer into Photoshop to work on. I rebooted Lightroom and Photoshop a couple of times with no effect still the same problem. I rebooted the computer twice and still no changes in the way it was responding. This morning as I begin to write this, I opened Lightroom and now even the catalog is missing along with most of the ones I have created. I did open an old one and it now works as it should so I will try to recreate the project from yesterday but it is now saying that Lightroom can't save to that Hard drive.  I will reboot the external hard drive now to see if that will solve that problem. This has happened in the past when using Photoshop when I am trying to save an image but never like this? Most of the time rebooting will solve that kind of issue so I will try that now. Just not sure what might be causing that to happen either?
    Thank you for your help,
    Charles

  • Image not showing for podcast

    Hello, I can't seem to get my image to show in my podcast. Everything else checks out OK. prettygoodgig uses Wordpress and feedburner. The image shows on the feedburner site. It has been about 3 weeks and still does not show in itunes.
    I have tried changing the name and location of the image but have had no luck.
    Here is the xml code for the podcast up to the first episode:
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2enclosuresfull.xsl"?>
    <?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?>
    <rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
    <channel>
    <title>pretty good gig podcast</title>
    <link>http://prettygoodgig.com/wordpress</link>
    <description>Interviews and conversations with musical people.</description>
    <lastBuildDate>Tue, 25 May 2010 14:10:11 +0000</lastBuildDate>
    <generator>http://wordpress.org/?v=2.9.2</generator>
    <language>en</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/prettygoodgig/idai" />
    <feedburner:info uri="prettygoodgig/idai" />
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" />
    <media:copyright>copyright 2010</media:copyright>
    <media:thumbnail url="http://prettygoodgig.com/images/ituneslogo.jpg" />
    <media:keywords>musicians,singer,songwriter,recording,music,marketing,music,care er,performing,gigs</media:keywords>
    <media:category scheme="http://www.itunes.com/dtds/podcast-1.0.dtd">Music</media:category>
    <itunes:owner>
    <itunes:email>[email protected]</itunes:email>
    <itunes:name>Bill Kahler</itunes:name>
    </itunes:owner>
    <itunes:author>Bill Kahler</itunes:author>
    <itunes:explicit>no</itunes:explicit>
    <itunes:image href="http://prettygoodgig.com/images/ituneslogo.jpg" />
    <itunes:keywords>musicians,singer,songwriter,recording,music,marketing,music,car eer,performing,gigs</itunes:keywords>
    <itunes:subtitle>Conversations and interviews with musical people</itunes:subtitle>
    <itunes:summary>This is a podcast where we talk to musicians about their experiences and share stories and advice, etc. We will also be talking to engineers about the recording process, production, gear etc. Other potential podcasts will feature subjects like teaching, buying a guitar, theory, inspiration etc.</itunes:summary>
    <itunes:category text="Music" />
    Thanks,
    billkahler
    prettygoodgig.com

    iTunes is not using the Feedburner-generated feed (which appears to be what you quoted: I can't examine the original because you haven't quoted the URL): it is using the Wordpress-generated feed which presumably you also submitted to Feedburner. This feed does not contain an 'itunes:image' tag, which is why there is no image in the Store.
    No amount of messing about with the Feedburner feed xml is going to affect the Store. You need to either a) add the appropriate tags to the Wordpress feed at the URL quoted above, or b) put a redirecting tag into that feed so that iTunes will transfer its attention from that to the Feedburner feed - the method is described here:
    http://www.apple.com/itunes/podcasts/specs.html#changing
    Be extremely careful if you choose option 'b': if you make an error in the URL for the feed you are redirecting to you will *not be able to get iTunes back to the correct feed*; and once you are using Feedburner's feed you will not be able to get at it to redirect away from it should you ever wish to do so in future. You should also make absolutely sure that the Feedburner feed is OK - check it at
    http://www.feedvalidator.org

  • Images not Drawn Properly

    I am simply trying to draw an image over a JPanel and it will not appear until the JFrame has been minimised or hidden behind something. Ive tried all kinds of repainting. Ive seen this topic before, but none seems to have a clear answer. HEPL! please

    "C:/JCreatorLE/MyProjects/Cards/images/CA.jpg"
    What the &%*$? is it doing way over there?, put it in the same folder   Container c    = getContentPane();
       JPanel panel = new JPanel(){
          public void paintComponent(Graphics g)     {
            ImageIcon img = new ImageIcon("CA.jpg");
            g.drawImage(img.getImage(), 0, 0, null);
            super.paintComponent(g);
       panel.setOpaque(false);
       c.add(panel);

  • Image not rendering for html signature

    I've created a CSS signature for my Mail signature (found at http://allforces.com/2006/04/14/css-signatures/) But no matter what I do the image (my logo) won't appear in the message. it's as if it can't find it on the machine. But when I open the file in Safari to create a webarchive, the image is rendering there. But when I save that webarchive and replace the signature file the image doesn't appear in the signature.
    Anyone have any ideas?

    ok I tried the instructions in that link and you are right, it is broken but it worked for me in one situation. If I create an html file using locally stored images and then convert it to a signature as outlined in this link it shows up correctly in the signature window in Mail prefs but the images don't show inside the message when i actually try to use the signature. Bummer.
    However, when I made an html file using images stored remotely on a webserver, the effect was the opposite! The pictures didn't show in Mail prefs but they did work correctly in Mail composition window and on the recepient end. Very weird and certainly a bug but it's a semi workaround I guess.

  • Q:Lists with images not working for me

    Gang,
    I am tryingto create a main page with a anumber of images pointing to different URLs. The main page is basically a list with images tied to it, pretty straightforward.
    However, I can't get the images to be displayed at all. Check out the test app here:
    http://apex.oracle.com/pls/otn/f?p=39193 (login: demo/demodemo)
    The workspace name is ANDYTEST.
    The images are loaded and are not associated to any application. If I check the source of the page I get the following:
    img src="/i/themes/generic_list.gif" width="128" height="128"
    And the width and height part is something that I have added to the attribute of the list entry.
    What am I doing wrong, andy ideas is excellent!
    Cheers,
    Andy

    Hello,
    The list template has a generic image so when the end developer (you) first implements a dropdown list you don't see a broken image.
    What you need to do is edit the List templat and take the image tag that looks like this
    &lt;img src="#IMAGE_PREFIX#themes/generic_list.gif" #IMAGE_ATTR# />and make it this
    &lt;img src="#IMAGE#" #IMAGE_ATTR# />I fixed up your example and you can see the images now.
    Regards,
    Carl
    blog : http://carlback.blogspot.com/
    apex examples : http://apex.oracle.com/pls/otn/f?p=11933:5

  • OT: Supplying Images (not free) for a client

    Hi all,
    This post refers to images that must be purchased.
    If a client asks you to provide image(s) for their website
    how do you go
    about showing the client what you recommend?
    Do you send them a link to the page with the potential
    image(s)
    or
    Do you download the watermarked image)s) and stick that in
    the design to
    show the client
    or
    Do you just buy the image and then stick it in the design and
    show the
    client
    or
    Do you do something else
    Thanks
    BW

    Thanks for the feedback, it's very helpful
    "Osgood" <[email protected]> wrote in
    message
    news:epq53q$rpe$[email protected]..
    > Depends what photo library youre are using. If its one
    at the cheaper end
    > of the scale such as istockphoto.com or dreamstime.com,
    which sell images
    > at incredibly cheap prices I would tend to purchase the
    image/s and put
    > them in the design, especially if they need to be
    enlarged. Most of my
    > work calls for enlarged images and low res ones aren't
    any good for that.
    >
    > However if its for web-work where images tend to be
    smaller I might just
    > download the water-marked images and put them in the
    design.
    >
    > Also most photo libraries have the facilities to put the
    images into a
    > portflio so you could just send the client to the
    portfolio page. I don't
    > tend to do that beacuse I put a mark-up on the images
    and don't want my
    > client to see how much they actually cost.
    >
    > Obviously if its an Image from one of the more 'besoke'
    expensive libraies
    > such as 'imagebank' then yuoll have to use the
    water-marked version to
    > show the client.
    >
    >
    > BW wrote:
    >> Hi all,
    >>
    >> This post refers to images that must be purchased.
    >>
    >> If a client asks you to provide image(s) for their
    website how do you go
    >> about showing the client what you recommend?
    >>
    >> Do you send them a link to the page with the
    potential image(s)
    >>
    >> or
    >>
    >> Do you download the watermarked image)s) and stick
    that in the design to
    >> show the client
    >>
    >> or
    >>
    >> Do you just buy the image and then stick it in the
    design and show the
    >> client
    >>
    >> or
    >>
    >> Do you do something else
    >>
    >> Thanks
    >>
    >> BW
    >

  • Background images not coming for taskflows extended in webcenter.

    Hi,
    I have created an ADF Task flow.The jsff page has a pop up which contains a backgroung image.But when i extend the adf task flow as a shared library in webcenter,I have not abloe to see the background image in webcenter.
    Thanks,
    Ananya

    Hello Doctor,
    I am not sure but could it be related to SU01 --> Defaults --> Delete after output option
    Or with note 1468596 - Trivial job logs are automatically deleted
    Can you check?
    Regards,
    Yuksel AKCINAR

  • Aperture Images not available for syncing

    I just upgraded to iTunes 10.7 and Aperture 3.4. ITunes sees all the albums in Aperture, but only a handful of the photos in each album. I synced to my iPhone 4 with iTunes 10.6 yesterday with no problem. Trying to sync to iPhone 5. Any help?

    To add to William Lloyd's advice:
    You may have a problem with your Aperture library.
    Have you tried the "Aperture Library First Aid Tools" and repaired or rebuilt the Library? See: Repairing and Rebuilding your User Library
    Or the iPod Photo Cache is corrupted - then you need to delete it from your Aperture Library package: see this support article:
        iTunes: Understanding the iPod Photo Cache folder
    Regards
    Léonie

  • (Linecard image not present) at WS-SSC-600 and 7600-SIP-400

    i install two modules WS-SSC-600 and 7600-SIP-400 in slot 5 and 6 in 13-slot chassis and give this output from show power (Linecard image not present)
      for both cards.
    supervisor engine is : VS-S720-10G with sub-module VS-F6K-PFC3CXL and VS-F6K-MSFC3
    IOS : s72033-advipservicesk9-mz.122-33.SXI9
    what that mean and how to fix it ?

    Ok problem solved by upgrade ios to another version but the new image must contains (_wan) in image name for example (
    s72033-advipservicesk9_wan-mz.122-33.SXJ6 ) otherwise the two modules will not powered up.

  • Image Processor not working for me. Help!

    In a nearby thread I've reached a stumbling block. Image Processor in CS4's PS is not working for me. I have a folder of psd's generated on the fly via File > Export > Data Sets as File... and now I'm trying to process those psd's to generate a JPEG of each. The only strange characteristic of the auto-generated PSD files is that there is no image preview available within the Finder. When a psd is selected the preview pane reads:
    "This layered Photoshop file was not saved with a composite image"
    I've verified in my Preferences > File Handling that image previews are always saved. (But I've been using PS for a long time and previews are always available with all my manually saved work.)
    So here's what happens when I invoke File > Scripts > Image Processor...
    In section 1 of the menu I select the source folder where the psd files reside
    In section 2, I select 'Save in same location'
    In section 3, I select 'Save as JPEG'
    In section 4, I change nothing. No special actions. Include ICC profile is checked.
    When I select run I get an error message: "Sorry, I could not process the following files:"
    And then it lists what appears to be 3 lines per psd file in the source directory:
    The path to the source dir
    The name of the source dir
    The [source_dir]/[filename.psd]
    What am I doing wrong?

    mrdior wrote:
    I have a folder of psd's generated on the fly via File > Export > Data Sets as File... and now I'm trying to process those psd's to generate a JPEG of each. The only strange characteristic of the auto-generated PSD files is that there is no image preview available within the Finder. When a psd is selected the preview pane reads:
    The part I don't understand is the "export" Part. File > Export > Data Sets as File.. on my machine is grayed out so I don't know how this feature is used. Is Export > Data Sets as File... used with CSV data sets and Photoshop variables?
    Check your Photoshop preferences and make sure you have set in the file handling tab "Maximize PSD and PSB File Compatibility:" to Always using the pull down menu. If that is not your current setting try setting that to see if the exported PSD files contain composite previews. When I use save as PSD on my system I alway see Photoshop save through up a popup window stating generating composite preview image.

  • I've been editing images with ease for a long time but now the changes are not being saved.

    I've been editing images with ease for a long time but now the changes are not being saved.
    Also, it is not liking me adding a large ammount of images in one go?

    Remember: we cannot see your machine. There are 9 different versions of iPhoto and they run on 8 different versions of the Operating System. The tricks and tips for dealing with issues vary depending on the version of iPhoto and the version of the OS.  So to get help you need to give as much information as you can. Basic things like :
    - What version of iPhoto.
    - What version of the Operating System.
    - Details. As full a description of the problem as you can. For instance: 'iPhoto won't export' is best explained by describing how you are trying to export, and so on.
    - History: Is this going on long? Has anything been installed or deleted?
    - Are there error messages?
    - What steps have you tried already to solve the issue.
    - Anything unusual about your set up? Or how you use iPhoto?
    Anything else you can think of that might help someone understand the problem you have.

  • It is not unusual for me to have a half dozen + copies of a single image. I am not creating these additional images which appear spontaneously myself so system must be  causing them. I have Elements 12 and operating system Windows 7.

    I have Elements 12 and operating system Windows 7. It is not unusual for me to  have a half dozen + copies of a single image. I am not creating these additional images myself, so must be the system. Deleting (including from the hard drive) does not help. Can anyone help please?

    1- The only way for picture files to be automatically added to the catalog is to allow the 'watch folders' option in the file menu and not choosing to have the organizer warn you of any addition. If those files are already in the catalog they should be ignored, only new files should be added.
    2- Otherwise, there is a downloader option to ignore duplicates when you import from camera or card reader to avoid importing several times from the same card.
    The Organizer considers files are duplicate when they have the same 'date taken' and size in Kb.

Maybe you are looking for