IAmJordanX / macwidgets

Automatically exported from code.google.com/p/macwidgets
0 stars 0 forks source link

Rating cell renderer paints incorrectly #100

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The RatingComponent is now transparent and does not draw correctly anymore when 
used as a 
renderer inside a table. The renderer needs to control the opacity now, too. I 
also noticed that 
the renderer does not use the "isSelected" flag passed to it. Instead it goes 
back to the table and 
checks the selection state of the current row, which is less efficient.

I changed the code on my machine to look like this and now it works:

     @Override
    public Component getTableCellRendererComponent(
            JTable table, Object value, boolean isSelected, boolean hasFocus,
            int row, int column) {

        super.getTableCellRendererComponent(table, value, isSelected, hasFocus,
                row, column);

        Rating rating = (Rating) value;

        // grab the cached rating component for the corresponding rating.
        RatingComponent renderer = fRatingsToRatingComponents.get(rating);
        renderer.setFocused(table.hasFocus());
        renderer.setSelected(isSelected);
        renderer.getComponent().setOpaque(isSelected);
        renderer.getComponent().setBackground(getBackground());

        return renderer.getComponent();
    }

Dirk

Original issue reported on code.google.com by dlemmermann@gmail.com on 22 Jun 2009 at 6:52

GoogleCodeExporter commented 9 years ago
Can you show a screen shot of the problem?

Original comment by kenneth....@gmail.com on 24 Jun 2009 at 7:37

GoogleCodeExporter commented 9 years ago
I could but then I have to change the code, generate a new JAR, add to my 
project, etc.... 
Believe me, the rating component background needs to become opaque otherwise 
the user can "see through" and 
see the color of the row, but not the selection color.

Original comment by dlemmermann@gmail.com on 24 Jun 2009 at 7:46

GoogleCodeExporter commented 9 years ago
Added custom CellRendererPane to ITunesTableUI delegate that makes the renderer 
component non-opaque if 
necessary, and also adds a line border to the bottom of the component if it is 
selected. 

Original comment by kenneth....@gmail.com on 26 Jun 2009 at 11:35