Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / December 2003

Tip: Looking for answers? Try searching our database.

Table cell rendering doesn't work at all !

Thread view: 
Chris Klein - 24 Dec 2003 13:25 GMT
Hello.

Since a few days I permanently try to set up a Cell Renderer on my table
in order to wrap the text in my cells via TextArea.
But I think my Renderer is never invoked !!!

The following test shows it:

class MyTableRenderer extends TextArea implements TableCellRenderer
  {
        
    private JTextArea ta;

    public MyTableRenderer()
      {
    ta = new JTextArea();
    ta.setLineWrap(true);
    ta.setWrapStyleWord(true);
    ta.setOpaque(true);
      }
        
        
     public Component getTableCellRendererComponent(JTable table,
Object
                           value, boolean isSelected, boolean hasFocus,
                           int row, int column)
        {
            

              System.out.println("Rendering works!!!");

// This console message I never get and so I think the renderer doesn't
// even get invoked!

              ta.setText(value.toStirng());
              return (Component)ta;     // "return this" would do the

                                        // same but i wanted to be sure
                                        // to exclude any error source

        }

  }

As said above I don't get the console message. So the
getTableCellRenderer method is NOT invoked, right!?

Furthermore I can assure that I didn't forget to do the following:

MyTableRenderer ren = new MyTableRenderer();                
table.setDefaultRenderer(String.class, ren);

I would be very glad if someone could help me with this problem.
Ok I now do my wrapping via HTML but i don't judge this solution
as elegant and furthermore i think that i'll possibly need the
renderer in the future....!!

greets.
c.klein
Tor Iver Wilhelmsen - 25 Dec 2003 10:35 GMT
> table.setDefaultRenderer(String.class, ren);

Does your tablemodel's getColumnClass() also return String.class for
any columns of interest? Remember the default model returns Object.
Chris Klein - 26 Dec 2003 00:40 GMT
>>table.setDefaultRenderer(String.class, ren);
>
> Does your tablemodel's getColumnClass() also return String.class for
> any columns of interest? Remember the default model returns Object.

Yes this was the problem.. Thanks for that note.

greets
c.klein


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.