Problem showing imageicon in cell using TableCellRenderer

Hi all,
I am using a tablecellrenderer to display an icon in a particular jtable column to reflect a value in the underlying model.
When I do this, the column does not display the ImageIcon at all. My code for the CellRenderer is below.
It should also be noted that I use another table cell renderer on the whole table to remove the line around the selection on the selected cell. This all works fine.
public class StatusCellRenderer implements TableCellRenderer {
    private static ImageIcon blueIcon = new ImageIcon("images/blue.gif");
    private static ImageIcon redIcon = new ImageIcon("images/red.gif");
    private JLabel label = new JLabel();
    // Constructors
    public StatusCellRenderer() {
        label.setHorizontalAlignment(JLabel.CENTER);
        label.setVerticalAlignment(JLabel.CENTER);
    // TableCellRenderer interface implementation
    public Component getTableCellRendererComponent(JTable table,
    Object value,
    boolean isSelected,
    boolean hasFocus,
    int row,
    int column) {
        if (Integer.parseInt(value.toString()) > 0){
            label.setIcon(blueIcon);
            label.repaint();
            return label;
        else if (Integer.parseInt(value.toString()) == 0){
            label.setIcon(redIcon);
            label.repaint();
            return label;
        else
            return null;
}

First question: What do you see in the column where you expect the Icon?
First suggestion: extend DefaultTableCellRenderer instead of implementing TableCellRenderer interface. Just a suggestion.
second question: Have you set the renderer for the class of objects in target column to be the StatusCellRenderer?
As camrickr says you need to post a little more code. Maybe a SMALL demo program illustrating your problem. Use code tags for legibility.
Cheers
DB

Similar Messages

  • Problems showing german special characters using DB2 jdbc driver

    Hi JDBC gurus,
    In my application the special german characters(umlauts...) are not shown correctly when I'm using IBM jdbc driver(type 2). When I switch to jdbcodbc driver everything is correct. So is there any trick, some connection parameter, some property or something like this? Something like "setCharset" or "umlauts" or something? I could not find anything in web :-(
    It is also hard to imagine that nobody has faced this problem. Or it is very trivial...
    The second problem:
    I have downloaded a new driver (com.ibm.db2.jcc.DB2Driver) but when I try to connect with DB I'm getting
    com.ibm.db2.jcc.b.SqlException: No license present. What does it mean - no license? I'm going to clear with our DB admin if the reason can be that I have no rights to connect directly with DB without having client installed locally on my PC. This is only what comes to my mind.
    Environment:
    DB: DB2 7.x
    Web-Server: Tomcat 5.x
    Hibernate 3.1.x

    Actually the problem is ONLY symbol � - scharfes S. Other umlauts are shown correctly...
    What is wrong with that symbol????
    Many thanks in advance,
    Giorgi

  • I am attempting to have cells use data from a selective month from the year before so that I can show actual from the prio. years each month.

    I am attempting to have cells use data from a selective month from the year before so that I can show actual from the prio. year each month. I need to create a spreedsheet using the the Acutlas from the year-to-date and from last year-to-date, but need to report each month.

    Hi Tony,
    Answering your question would be easier given a screen shot of the source table and one of what you want the summary table to look like.
    Is the data you want for each month in a single cell o the source table, or does the summary table need to collect February's data (for example) from several cells and do some math with those numbers before presenting them on the summary table?
    Regards,
    Barry

  • Problem showing Trademark symbol using ascii code in Flex 3

    I am facing problem in displaying trademark symbol (™) using ascii codes(it is showing square symbol). I have ascii code stored in the database for trademark symbol(ascii code "™" ). So I can't use Hexa code instead of ascii code. But using ascii code I am able to show copyright symbol. Following is the sample code :
    <?xml version="1.0"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
        <mx:Script>
            var trademarkSymbol = "\u2122";
            var trademarkSymbol1 = "&#153;";
            var copyrightSymbol = "\u00A9";
            var copyrightSymbol1 = "&#169;";
        </mx:Script>
        <mx:Label text="Macromedia™"/>
        <mx:Label text="Macromedia{trademarkSymbol}"/>
        <mx:Label text="Macromedia{trademarkSymbol1}"/>      \\ problem  code
        <mx:Label text="Macromedia©"/>
        <mx:Label text="Macromedia{copyrightSymbol}"/>
        <mx:Label text="Macromedia{copyrightSymbol1}"/>
    </mx:Application>
    Please suggest some solution.
    Regards
    Rajat Sahni

    You must use Unicode values, not Windows extended ASCII values.
    The Unicode value of a copyright symbol is hex 00A9 or decimal 169. This happens to be the same as where it is in a Windows' extended ASCII character set, but this is irrelevant. The Unicode value of a copyright symbol is hex 2122 or decimal 8482. In Windows' extended ASCII it has a different value, hex 99 or decimal 153, but again this is irrelevant.
    So the reason you think it "works" for the copyright and not for the trademark is that the two character sets agree on the value of the copyright but disagree on the value of the trademark.
    Moral: Find a good Unicode table.
    Gordon Smith
    Adobe Flex SDK Team

  • How do I set background color of cell using JTable?

    Hello all!
    I have a question on the use of JTables. I am using a JDialog consisting of a JTable and a number of buttons to insert and to select OK or cancel. Everything is working perfectly, but I now must add editing capabilities to prevent invalid data being used in a SQL query to update or insert rows.
    So far I can't figure out how to get at a cell to set the background to red if the user inputs a Date incorrectly. Upon setValueAt(), I take this value and check for standard format errors. I hope to someday convert the column altogether to a Data object (or some form since Date is deprecated):-) For the time being, I know when an error occurs, but don't have the foggiest idea how to render the error (set backround to red).
    I need to give you more info too, since the way we do things is to make it as complicated as possible for job security and to impress the newbies(or scare them back to COBOL). When I setValueAt(), I have a DefaultDataElement object that houses everything for a given column in DB2. It has column name, length, data type, is it new, original value, current value, etc. If one doesn't exist, then I create one. After all said and done, I parse thru these elements and build my update/insert query and then execute the query.
    The event starts as soon as the user presses the OK button. But, if a date cell contains an invalid date, I need to halt processing (which I've done) and somehow let the user know which cell was invalid. We consider our users dumb (they really aren't, but the assumption is made), so I can't just say "error occurred in table. Verify data and try again". That won't work:-) Gotta be able to show them what cell is bad.
    Any ideas?
    Thanks,
    Patrick

    I finally figured it out. I was always close, but it wasn't until late yesterday that the light bulb came on. I was setting the background on the component in getTableCellEditorComponent() by grabbing the super.getTableCellEditorComponent(). The problem was all this was located in an editor, not renderer. So what happened was as I edited the cell the check would be performed then, not as focus was lost. When focus was lost, the red background went back to normal.
    I ripped the code out and made a custom renderer and got closer. Problem was the whole column had a red background. Even specifying the row and column in getTableCellRendererComponent didn't apply just to that cell. That row and column is only for obtaining the data in the cell, but anything affecting the component will affect the column, since I added the renderer to my TableColumn:-) I need to add error logic to my model and when an error occurs, set a boolean flag in a 2 dimensional array where the row and column is used to get to it from the renderer.
    Thanks for the help!!!

  • Website shows all the cells borders on ipad. Please help!

    Hi Guys,
    I am a new member.
    I just realized that only on ipads and iphones, my website www.carmenguedez.com shows all the cell borders.   Every page has a table defined in HTML/CSS and the borders are hidden in all browsers viewed from PC's. How can I fix it?
    My husband and I created my website from scratch using dreamweaver and reading online tutorials, etc. We are not experts in web development and I couldn't find an answer online.
    How can I hide these cells borders?
    Please help!
    Thank you,
    Carmen

    I found the solution to my problem. I just nedded to add the bg color to my table:
    <table width="831" align="center" cellpadding="0" cellspacing="0" class="Table_Border">
    I changed to: <table width="831" align="center" cellpadding="0" cellspacing="0" class="Table_Border" bgcolor="#35281c">
    Now, the table borders don't show on ipads.
    Thanks.
    Carmen

  • We have a corporate iPad in our auto showroom to show guests how to use features on their vehicles. Someone locked it with their account. It was not an employee. How can I get in? I did a restore of the software already?

    We have a corporate iPad in our auto showroom to show guests how to use features on their vehicles. Someone locked it with their account. It was not an employee. How can I get in? I did a restore of the software already?

    Gather up the proof that the dealership is the original purchaser of the iPad,
    and take the iPad & that proof to a physical Apple store for possible assistance.
    It is highly suggested that you make a genius bar appointment to avoid delay
    at the store:
    Make a Genius Bar Reservation
    http://www.apple.com/retail/geniusbar/
    If no Apple store close by, get the information mentioned above and contact
    Apple Contact Us for assistance.
    Once the problem is resolved, you may wish it use Guided Access to limit
    what customers can do with the iPad.
         iOS: About Guided Access - Apple Support

  • Create heck box in excel cell using sap

    Dear Sap Master's,
    Please give me some idea on how to create a check box in excel cell using abap program..
    (OLE concept).
    Thanks,
    Naveen.
    Moderator message: please do some research before posting, show what you have done yourself when posting.
    Edited by: Thomas Zloch on Jan 17, 2012

    Not resolved

  • Problem showing atf in air 3.4 captativeruntime

    Hi,
    I can't show atf images in my captative runtime version of a game for android, but yes in the non captative runtime version .
    What can be wrong?
    It is possible that the air bundled  version was not 3.4 version?
    Edit: NativeApplication.nativeApplication.runtimeVersion  = 3.4.0.2540  so the air version is correct for atf images support.
    I forget to mention that i using starling ,but hte captative version only show flash native elements like the textfield i used to trace the air version
    The atf images are there because i can start the game if i touch the play button where is supposed it to be.
    Thanks

    http://forum.starling-framework.org/topic/problem-showing-atf-in-air-34-captativeruntime
    "I compressed the png's with "png2atf -c -i starling-atf.png -o starling.atf" so in all available formats and it Works! .
    So is like the captative air 3.4 version can't handle the ETC compression?

  • POP3 & IMAP Email setup for both Wifi & Cell use separately...

    Hello,
    I was asked to post info about this by an iPhone support rep.
    I initially had lots of trouble setting accounts for use with both my WiFi home and office networks and for use through the ATT cell network.
    If you have a question as to how to setup email for both WiFi and Cell use, answer is you can't configure these manually and you don't want to...the phone does this automatically...and seamlessly. (you will NOT see the change in the advanced settings menu, this occurs internally, the settings appear the same)
    The problem: Accounts changing settings automatically...when manually configuring two separate accounts with the same email address but trying to setup the outgoing settings for different ports...one for WiFi (your broadband server acct / port 587) and one for Cell (cwmx.com / port 25)...THIS WON'T WORK!! My WiFi configured email accounts would automatically switch to Cellular configured email accounts as long as they had the same email address. Even though I gave them different names, the phone looks at the "actual email address" and if they are the same it changes your configuration to match the other account (it does this by matching the account that was either ON or OFF first and as soon as you match the second account to that setting (either ON or OFF) the phone switches the settings to match the first account.
    The Solution: (End of the Story first for those who have or are facing this problem): Be sure to setup the email accounts for use with your WiFi account first (and ONLY), as when you leave the WiFi area or turn off the WiFi setting the email account will automatically reconfigure itself for use with the ATT Cellular network...then the settings will switch back when you re-connect to the WiFi area(s). The settings that you will "SEE" are your setup for WiFi, this will not change even when using the Edge network (at least not what is displayed in the "advanced" menu). You will still see Port 587, even though the phone is changing setups internally and changes back once back on a WiFi network, you just don't see the changes.
    *I hope this helps!*
    (more details below for those who might be interested and _for those who may be trying to setup using COMCAST Broadband_)...
    My issue began because I could not get my Comcast setup to work for outgoing email. So I was advised to setup for the Edge port settings by an iPhone support person from ATT...this was a huge error. Because I attempted to do this it actually kept the phone from smoothly converting settings as needed. I only discovered this after resolving the actual problem with my WiFi (Comcast Broadband settings) issue which was actually the setup that MUST HAVE a user ID and Password, at least when using a Comcast Broadband account. Unlike the rest of my XP and ME computers on my networks which do not require this info, the iPhone DOES.
    Because I could not get outgoing mail to work with my broadband setup I attempted to setup two accounts for each email address...one for Cellular and one for WiFi for when I would figure out my problem...or for just sending email more quickly. This does not work as the conflict causes a nightmare. This is something the iPhone support folks should have explained but failed to do so, perhaps as they didn't know this?
    Bottom line: Let the phone do the choosing...it works great and will avoid YOU wasting TWO DAYS and more than 12 hours on the phone with iPhone Support as I did. I eventually figured the port switching issues and solutions on my own through trial and error and luckily one bright iPhone support person advised me that he knew for sure that when using the iPhone with Comcast you must setup "outgoing settings" using an "ID" and "Password" which I was provided by Comcast in only a few minutes. I don't use their emial account but I setup one just for this purpose. Once done, my email accounts began working normally. Once I resolved the conflict issues listed above the phone now works great both WiFi and Cell.
    -Rich

    fullspool,
    Comcast offers an authenticating SMTP server that should work for you on WiFi and EDGE both.
    The settings are linked in this Apple knowledge base article:
    http://docs.info.apple.com/article.html?artnum=306074
    The Comcast link is:
    http://www.comcast.net/help/faq/index.jsp?faq=Emailtop18913
    From that link the settings are:
    Your email address: [email protected]
    The email server type (POP)
    Incoming mail server: mail.comcast.net
    Outgoing mail server: smtp.comcast.net
    With SSL on for both incoming and outgoing.
    Hope this helps,
    Nathan C.

  • On my iPad mini, my inbox number count is over 500 even though the inbox. Is empty. All accounts do this on my iPad but all my other device are fine. Problem showed up two weeks ago???

    On my iPad mini, my inbox number count is over 500 even though the inbox. Is empty. All accounts do this on my iPad but all my other device are fine. Problem showed up two weeks ago???

    Hi Peter,
    Thanks for participating in the Apple Support Communities.
    It sounds like the Mail app on your iPad mini is showing that you have over 500 unread email messages, but your inbox is actually empty.
    There are several steps I'd use to troubleshoot this situation.
    First, restart your iPad to see if it clears up the symtom:
    Restart or reset your iPhone, iPad, or iPod touch - Apple Support
    Press and hold the Sleep/Wake button until the red slider appears.
    Drag the slider to turn your device completely off.
    After the device turns off, press and hold the Sleep/Wake button again until you see the Apple logo.
    If this doesn't correct the behavior, try removing and re-adding the affected email accounts next:
    Get help with Mail on iPhone, iPad, and iPod touch - Apple Support
    Delete the affected email account from your device.
    Tap Settings > Mail, Contacts, Calendars.
    Tap the affected email account.
    Tap Delete Account.
    Add your account again.
    If the same thing happens after re-adding the account, you may need to use the steps below to reinstall iOS. You may want to back up your iPad to iTunes before completing this step.
    Make sure that you have iTunes 12 or later on your computer.
    Put your device in recovery mode.
    When you get the option to restore or update, select Update. This will reinstall iOS without erasing your data.
    From:
    If your iPhone, iPad, or iPod touch doesn't respond or doesn't turn on - Apple Support
    All the best,
    Jeremy

  • Problem with select all cells in JTable

    Hi guys! I get some problem about selecting all cells in JTable. I tried to used two methods:
    1> table.selectAll()2> changeSelection(firstcell, lastcell,false,true)
    firstcell:[0,0], lastcell[rowcount-1,colcount-1]
    Result: only the first row selected when i use both methods.
    Note: i set up the selection model as following:
    this.dataSheet.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
                    this.dataSheet.setCellSelectionEnabled(true);
                    this.dataSheet.setRowSelectionAllowed(true);
                    this.dataSheet.setColumnSelectionAllowed(true);Thanks !

    What selection properity should be changed in order to enable selectAll() method work properly? Is there Any constraints? Here is the TableModel I am using. And i set up selection mode use the following code:
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setCellSelectionEnabled(true);
    table.setRowSelectionAllowed(true);
    table.setColumnSelectionAllowed(true);
    import java.util.Vector;
    import javax.swing.table.*;
    import javax.swing.JTable;
    public class DataSheetModel extends AbstractTableModel{
              private Vector data = new Vector();//Store data
              private Vector columnNames = new Vector();//Store head
              public DataSheetModel(){}
              public DataSheetModel(Vector headVector, Vector dataVector){
                   if(headVector != null) this.columnNames = headVector;
                   if(dataVector != null) this.data = dataVector;
              public int getColumnCount(){
                   return columnNames.size()+1;
              public int getRowCount(){
                   return data.size()+1;
              public String getColumnName(int col){
                   if(col==0) return "";
                   else return (String)columnNames.get(col-1);
              public Object getValueAt(int row, int col){
                   if(col==0) {
                        if(row != data.size()) return String.valueOf(row);
                        else return "*";
                   else{
                        if(row != data.size()){
                             Vector rowVector = (Vector)data.elementAt(row);
                             return rowVector.elementAt(col-1);
                        }else return null;
              public void setValueAt(Object value, int row, int col){
                   if(row != this.data.size()){
                        Vector rowVector = (Vector)data.elementAt(row);
                        rowVector.set(col-1,value);
                        this.data.set(row,rowVector);
                        this.fireTableDataChanged();
                   }else{
                        Vector rowVector = new Vector();
                        for(int i=0; i<this.getColumnCount()-1; i++) rowVector.add(null);
                        rowVector.set(col-1,value);
                        this.data.add(rowVector);
                        this.fireTableDataChanged();
              public Class getColumnClass(int c){
                   return getValueAt(0,c).getClass();
              public boolean isCellEditable(int row, int col){
                   if(col == 0) return false;
                   else return true;
              public void setDataVector(Vector head, Vector data){
                   if(head != null) this.columnNames = head;
                   if(data != null) this.data = data;
    }

  • 9300 Curve wifi problem - cannot connect to internet using only wifi once data turned off

    I've got a 9300 Curve with a data plan from Rogers. I want to use my wifi in hotspots when I go overseas without using my data. I have no problems connecting to wifi networks. Once I turn off my data services, my connections to the wifi network show that the signal is still just as strong, but I can't use my browser, facebook, bbm, etc. - message is "unable to connect to internet" when I try and access my browser. This problem occurs whether I'm using a public hotspot or my home router. I used to be able to access wifi without using data from Rogers on my older Curve (can't remember the model), so I don't think it has anything to do with my plan.
    Any suggestions/advice would be much appreciated!

    Thanks for the reply!
    Did you mean "leave data ON and turn off data roaming"? But that would just turn off my data while I'm roaming, and while I'm not roaming, it'll still access through data and not through wifi like I would prefer. That's what I understand, but pls correct me if I'm wrong! I guess I meant to also mention that whether I'm in my home zone or overseas, I still can't use my browser, bbm, etc through wifi only, with data turned off...it just says there's no connection to the server/internet, even though it shows that I'm connected to a wifi network.

  • Problem changing default key bindings using Oracle Terminal

    Hello,
    I'm facing a problem changing default key bindings using Oracle Terminal. I changed
    some bindings, saved them in forms60/fmrusw.res, started the generation and saved again.
    I thought that's it but it wasn't. It took no effect at all in Forms (even after recompilation) although reopening the file in Terminal showed the changes. I'm using Forms in German, which means that even the key bindings displayed in Forms are translated i.e. STRG+F1 instead if CTRL+F1,
    but I can't find a german version of this resource file, so i think it's the same resource file for all supported languages. But what is needed for the changes to take effect ?
    Thanks in advance
    STD
    null

    Hi,
    is it client/server you are working?
    if so you should not be using the fmrusw.res file because I guess your NLS_LANG is German_Germany.WE8ISO8859P1 or something like that. This means the terminal that is being opened is fmrdw.res instead of fmrusw.res and this file should be edited using Oracle Terminal.
    if you are working via the web implementation than you can open the file fmrweb.res in a text editor and change the keybindings in there. If you need to have the PC like key bindings on the web just open the fmrpcweb.res and see if it contains the German texts. If so you can either copy this file over the frmweb.res file or you can specify term=fmrpcweb.res in the serverargs parameter.
    Hope this helps.
    Kind regards,
    Frank van der Borden
    Oracle Support Services
    Netherlands

  • Why is Ps and Dw now showing that I'm using a trial version?

    After using Ps and Dw CS6 since the cloud was released these applications are now showing that I'm using the TRIAL VERSION and they expire in 4 days! Yes, my subscription is vaild. The next auto billing is not until June 10th so I'm current. Yes, I've rebooted my PC. Yes, I have a connection to the internet at DSL speed that is a dedicated connection. Yes, I am running a dual core Itel Processor with 6gb of ram and 1 tb of HD. No, I have not made any software changes or installations since it was last working at 2:24Pm this afternoon. No, I have not exceeded my license agreement. These programs are installed and activated only on my PC and my laptop. No, Adobe Application Manager does not show that I need an update to either program.
    Is Adobe mad that I posted critical reviews concerning the Creative Cloud and this is my punishment? I'm sorry Adobe. I promise I'll be good and be quite if I can please have back the software and service I've paid for, I promise.
    Seriously, I know I've seen simular questions like this asked before but did not follow the thread for the answer and looking through the forum discussion area I do not see a recent question or answer for this. Does anyone know why this happens and if Adobe has an answer, fix or work-a-round?

    @Venzg - Thanks I'll keep those steps in mind for next time. This moring everything is working fine. Sometime in the night the fairies must have come and fixed it or more likely a server re-booted somewhere in the vast internet. You know what I find odd though? Not that it happened, we live in an imperfect world and screws fall out, but that it showed trial versions.
    Before I downloaded and installed the "Cloud" and Adobe Application Manager I deactivated and uninstalled all previous version of Adobe software including the TRAIL VERSIONS. That the TRAIL VERSIONS were displayed along with the seemingly correct number of days left on the trial tells me that an Adobe deactivation and uninstall is not complete. Persistant files exist after the uninstall and in my case this could lead to problems.

Maybe you are looking for

  • Birthdays a day early in Calendar on Mountain Lion

    On my Macbook Pro running Mac OS X 10.8.2 (Mountain Lion) all the birthdays from the "Birthdays" calendar are showing a day early in Calendar. E.g. When I browse to contact Joe Bloggs in Contacts it shows his birthday as 12/03/1987. When I go into Ca

  • How to load the data from flat file

    Hi , Im new to Oracle 10g . I have to upload a flat flle(notepad with , as a seperator) to the table in the database, can you please tell me how to do it ? Thanks vivi

  • How do I get to the logic board on a PSC 2210?

    I would like to swap a logic board from a known good machine to one which is having issues. How do I get it out? This question was solved. View Solution.

  • Link between ekko and vekp table

    Hi All, Can any let me know the relation ship or the connectivity for purchase order (ekko- ebeln) and Handling unit (vekp-exidv). i need to fetch the hu details based on the purchase order. required urgently. regards, Ak Edited by: arvind on Apr 11,

  • Need help to write query

    Hi I have following table structure Name Type HOSTNAME VARCHAR2(30) COL1 VARCHAR2(30) COL2 VARCHAR2(30) data inthe table is like this HOSTNAME COL1          COL2 H1               Authorized          Allowed H1               Authorized          Allowe