coderazzi / tablefilter-swing

TableFilter is a set of Swing components to support user-driven filtering on table.
https://coderazzi.net/tablefilter
MIT License
7 stars 2 forks source link

Setting of selection background and foreground effect is not immidiate #9

Closed coderazzi closed 9 years ago

coderazzi commented 13 years ago

Original report by Anonymous.


Hi!

I upgraded to 4.1.1 (Linux) version of filters and got this little but annoying issue.

My application uses Nimbus L&F,
thus selection background color is set using
UIManager.put("nimbusSelectionBackground",UIConstants.dashboardBGColor);
I wanted different colors for filter fields and
changed the colors of selected filter field using these lines:
filterHeader.setSelectionBackground(Color.white);
filterHeader.setSelectionForeground(Color.black);

However, when I open the screen and FIRST time select the filter above one of columns,
I see the UIManager color for 2 seconds, after this it changes to those I chose for
filter fields.

I'll be very happy if this little issue can be fixed.

Best regards,
Polina.

Original issue reported on code.google.com by pulke83 on 2011-03-16 15:28:15

coderazzi commented 13 years ago

Original comment by coderazzi coderazzi (Bitbucket: coderazzi, GitHub: coderazzi).


Hi, Polina,

I am trying to reproduce the problem, again using the TableFilterExample included on
the source distribution of the library. I am using Crunchbang as Linux distribution,
totally up to date. These are the steps I follow:

1- UIManager.put("nimbusSelectionBackground",Color.red);
  So I use red color to better notice any differences.

2- UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");

3- create and initialize the TableFilterHeader instance, but do not attach it to
   the table (although attaching it first makes no difference, in fact)

4- filterHeader.setSelectionBackground(Color.white);

5- filterHeader.setSelectionForeground(Color.black);

6- filterHeader.setTable(table);

I see no red at any moment on the filter header (any other selection outside does appear
in red).

If you download the source from http://coderazzi.net/tablefilter/download/tablefilter-src-v4.1.1.zip

and introduce the following changes:
1-In Constructor:
               setJMenuBar(createMenu(tablePanel, modelRows));
/*NEW*/        filterHeader.setSelectionBackground(Color.white);
/*NEW*/        filterHeader.setSelectionForeground(Color.black);
               filterHeader.setTable(table);

2- In static main method, input new code at its beginning:
   UIManager.put("nimbusSelectionBackground",Color.red);
   try{         
      UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
   } catch(Exception ex){}

And run it, do you still have the same problem???

Best regards,

  Lu.

Original issue reported on code.google.com by coderazzi on 2011-03-21 00:38:20

coderazzi commented 13 years ago

Original comment by coderazzi coderazzi (Bitbucket: coderazzi, GitHub: coderazzi).


Note: the changes are to be included in class 
net.coderazzi.filters.examples.TableFilterExample

Original issue reported on code.google.com by coderazzi on 2011-03-21 00:39:33

coderazzi commented 13 years ago

Original comment by Anonymous.


Hi Lu!

Thanks again for such a fast reply!

I think I found the workaround to the problem I had.
I was always passing the table on the creation of table filter instance,
but you suggested using :
filterHeader.setTable(table);
Turns out that this code works OK, meaning the red selection background doesn't appear
:
filterHeader = new TableFilterHeader();
filterHeader.setSelectionBackground(Color.white);
filterHeader.setSelectionForeground(Color.black);
filterHeader.setTable(resultsTable);//table is set after color settings

But if the table is set before setting colors, I see on first selection of filter field
red background:

filterHeader = new TableFilterHeader();
filterHeader.setTable(resultsTable); 
//same as filterHeader = new TableFilterHeader(resultsTable);
filterHeader.setSelectionBackground(Color.white);
filterHeader.setSelectionForeground(Color.black);

Best regards,
Polina.

Original issue reported on code.google.com by pulke83 on 2011-03-21 09:24:24

coderazzi commented 13 years ago

Original comment by coderazzi coderazzi (Bitbucket: coderazzi, GitHub: coderazzi).


Hi, Polina,

You could always set the colors on the FilterSettings singleton, something like:

FilterSettings.selectionForegroundColor=Color.white;

etc.

In this way, you do not need to setup each instance separately, or being careful to
set the table afterward.

Best regards,

 Lu.

Original issue reported on code.google.com by coderazzi on 2011-03-21 13:01:33

coderazzi commented 13 years ago

Original comment by Anonymous.


Hi, Lu,

this is great solution, really can't understand why I didn't do this from
beginning :)

Original issue reported on code.google.com by pulke83 on 2011-03-21 13:11:44

coderazzi commented 12 years ago

Original comment by coderazzi coderazzi (Bitbucket: coderazzi, GitHub: coderazzi).


(No text was entered with this change)

Original issue reported on code.google.com by coderazzi on 2011-11-14 23:12:23

coderazzi commented 9 years ago

Original comment by coderazzi coderazzi (Bitbucket: coderazzi, GitHub: coderazzi).


Already resolved (previously, before migrating to BitBucket)