[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How to render an icon in a JTable

Posted on 1998-09-06
2
Medium Priority
?
428 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 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

650 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