Skip to main content



      Home
Home » Eclipse Projects » NatTable » How to correctly use ButtonCellPainter?
How to correctly use ButtonCellPainter? [message #1137469] Mon, 14 October 2013 10:15 Go to next message
Eclipse UserFriend
I followed the Rendereing_a_cell_as_a_button example and did the following:


  1. Added a button cell painter to each cell with a specific label
  2. Added a ButtonClickConfiguration similar to the one in the example
  3. Added a click listener to the painter


But the button is neither shown as pressed nor is the click listener even called when clicking the button. What am I missing? When adding a LayerListener to my table which simply logs all received events, it only receives cell selection events.

EDIT: I did some more research:
When adding the configuration to the selection or the data layer of the table body, it is called, but the layer stack only contains the layer BODY, even if I attach the label accumulator right there. The label accumulator works correctly as the labels are used as a base for rendering, and the buttons are rendered correctly. Plus, the button does not appear pressed when I click it.

[Updated on: Mon, 14 October 2013 10:46] by Moderator

Re: How to correctly use ButtonCellPainter? [message #1137519 is a reply to message #1137469] Mon, 14 October 2013 10:54 Go to previous messageGo to next message
Eclipse UserFriend
How did you create the ButtonCellPainter? Did you specify two different painter or one interiour painter?
Did you ensure to add your ButtonClickConfiguration BEFORE calling natTable.configure()?

I haven't implemented the ButtonCellPainter nor have I ever used it before. Looking at the implementation scares me as it uses background threads to update the visualization. But I really don't know what happens.
Re: How to correctly use ButtonCellPainter? [message #1137532 is a reply to message #1137519] Mon, 14 October 2013 11:05 Go to previous messageGo to next message
Eclipse UserFriend
I did it this way:
final TextPainter flatCellPainter = new TextPainter();
final ButtonCellPainter bcp = new ButtonCellPainter(new BeveledBorderDecorator(flatCellPainter), new BeveledBorderDecorator(flatCellPainter, false));
config.registerConfigAttribute(CELL_PAINTER, bcp, NORMAL, MY_BUTTON_LABEL);
bcp.addClickListener(new IMouseAction() {

    @Override
    public void run(final NatTable natTable, final MouseEvent event) {
        // do stuff
    }
});


config is a ConfigRegistry.
Re: How to correctly use ButtonCellPainter? [message #1137667 is a reply to message #1137532] Mon, 14 October 2013 12:59 Go to previous messageGo to next message
Eclipse UserFriend
Are you doing this in a configuration? And when are you adding the configuration?
Re: How to correctly use ButtonCellPainter? [message #1176372 is a reply to message #1137667] Fri, 08 November 2013 04:40 Go to previous message
Eclipse UserFriend
Sorry for not answering this thread for a long time, but it turned out that I did not need buttons in that table. I came up with a combo box solution which just works fine. I wanted the button to be a "Delete" button in the last column of every row, which now opens a combo box where I can select "Yes" or "no". So I got a nice user confirmation without having to open a dialog box.
Previous Topic:Row numbers are also changed , when rows are reordered using row reorder layer
Next Topic:Select all column cells by clicking on column header
Goto Forum:
  


Current Time: Wed Jul 23 13:29:50 EDT 2025

Powered by FUDForum. Page generated in 0.04718 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top