Cell renderer/editor in Netbeans?

View: New views
4 Messages — Rating Filter:   Alert me  

Cell renderer/editor in Netbeans?

by bidi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi people, I couldnt make cell renderer specification for JTable in Netbeans? How can I do? If not in Netbeans, should I better use Eclipse or something? What do you suggest?
Thanks..

Re: Cell renderer/editor in Netbeans?

by Patrick Keegan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

bidi wrote:
> Hi people, I couldnt make cell renderer specification for JTable in Netbeans?
> How can I do? If not in Netbeans, should I better use Eclipse or something?
> What do you suggest?
> Thanks..
>  
Have you tried right-clicking the JTable, selecting Table Contents, And
clicking the Columns tab? You can set renderers and editors for the
columns there.

-Patrick

Re: Cell renderer/editor in Netbeans?

by FatButtLarry :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

bidi wrote:
Hi people, I couldnt make cell renderer specification for JTable in Netbeans? How can I do? If not in Netbeans, should I better use Eclipse or something? What do you suggest?
Thanks..
I'd like to bump this question back up.  I've tried what is suggested but I'm not sure where to go after I click the renderer.





I am trying to implement some custom cell rendering in a JTable that is inside a JDialog.  I am using the NetBeans IDE version 6.5 to drag the components in.  I'm using the editor to write my own cell renderer and then programatically apply it to the NetBeans-created table, but the table doesn't seem to call the renderer once the application has been loaded.

The screenshots illustrate the suggestion above indicating to use the GUI for cell rendering purposes.  Sorry the screenshots might be conflicting in that sense, as one says "<User Code>" and the other does not.   The message "Custom Editing of this Property is not supported." only shows when clicking "Component Chooser" from the render options).  Switching to user code didn't fix this issue, and I'm not sure how to implement it otherwise. (code below)

This is not the first time I've implemented a cell renderer programatically, but it is the first time I've attempted it through the IDE.  I'm willing to accept the mistake could be something I'm doing.

Also note that I'm not even getting my println()'s.  This suggesting that the render isn't getting called at all when I implement it through code.

Here's is a code snippet of what I've implemented:
[code]
    myTable.setDefaultRenderer(String.class, new MyCellRenderer());
[/code]


[code]
    public class MyCellRenderer extends JLabel implements TableCellRenderer {
        public Component getTableCellRendererComponent(JTable table, Object color,
                boolean isSelected, boolean hasFocus, int row, int column) {
           
            this.setForeground(Color.RED);
            this.setBackground(Color.BLUE);
            this.setText("BREAK THIS THING!");
            System.out.println("HERE");
            return this;
        }
    }
[/code]

-Tres

Re: Cell renderer/editor in Netbeans?

by FatButtLarry :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

bidi wrote:
Hi people, I couldnt make cell renderer specification for JTable in Netbeans? How can I do? If not in Netbeans, should I better use Eclipse or something? What do you suggest?
Thanks..
Ok, this was an easy one...

http://forums.sun.com/thread.jspa?threadID=243645&tstart=32684

Just had to change:
    setDefaultRenderer(String.class, new MyRenderer());

To:
    setDefaultRenderer(Object.class, new MyRenderer());

Hope this helps others!!!  Not a problem with NetBeans at all, sorry for the confusion.

-Tres