Solved

How to render an icon in a JTable

Posted on 1998-09-06
2
422 Views
Last Modified: 2008-02-01
I need help on how to render an icon in a JTable.
0
Comment
Question by:swilde
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
mjenkins earned 50 total points
ID: 1223699
Use this as your cell renderer for the column in question:

public class MyCellRenderer
{
      public Component getTableCellRendererComponent(
            JTable table, java.lang.Object value, boolean isSelected, boolean hasFocus,int row,int column)
      {      
            if( value instanceof Icon )
                  return new JLabel( (Icon)value );
            else
                  return new JLabel( value.toString() );
      }
}
0
 

Author Comment

by:swilde
ID: 1223700
Thanks for the response.  The only thing missing was that the class needed to implement TableCellRenderer.  The code worked like a charm.  Now if only I can figure out why it worked!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
hibernate example using maven 12 77
login form jsp example 2 49
Eclipse Java import and method not resolved 4 73
Java Inheritance super keyword use 8 32
In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question