• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Java table row property problem

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone, hope you are doing well

I have a problem that I can't figure out. So, I have a method setColor which sets tableRow of my Table to particular color where a certain condition is satisfied (the account has 'inactive' status).  





https://imgur.com/a/OD8qoJN
Everything works perfectly, but my row margins are disappearing.  I thought, ya that's not a problem I will fix it in a sec ... nope.


https://imgur.com/a/DernahP

As you can see alignment got out of sync.
I don't know what style should i use or what is maybe a completely different approach to solve this problem.
 
Bartender
Posts: 303
12
IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try adding the style with a new CSS style class instead of using setStyle().

Ex:


In your CSS (which hopefully you're already using) you'd have a style that looks like this:

 
Łukasz Kiepas
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome back

I tried your approach and it helped, but created another problem that I have been trying to solve for the past 4 hours.

I will try to explain it on an easier example: to-do-list
https://imgur.com/a/dvlevLw
When I lunch the app everything is working properly:
https://imgur.com/a/3ZeobUO
I have a database table and when the column (which is invisible) status is true whole row is green and when not whole row is purple - works fine !

But when I am deleting or trying to add new item everything messes up with random colored (always purple)
https://imgur.com/a/HaNx0Tk

Here is my setColor method:


Here is my filling Table method which also works fine except setColor(); method.
fillTable method is used after deleting from database and adding to database to show new data in table.





And my CSS file:


Here is a whole class if somebody would like to take a peek:
https://pastebin.com/tiKSYHn8
 
Łukasz Kiepas
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problem solved.
It was all about resetting the table.
https://imgur.com/a/h2hcwwL
 
Lou Hamers
Bartender
Posts: 303
12
IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From a quick scan of what you're doing above, you may have been having an issue because you were always adding style classes and never removing them. If you observe the styleclass list that getStyleClass() returns, you'd see that repeated calls of add() make it longer and longer.

It sometimes doesn't cause a problem when we do repeated adds like that, because one class overrides the other, but if you do it too much I can't imagine it being good for performance. So when I add style classes like that to deal with table styles, I usually remove all the ones that may have been added before adding the new one.

The solution you found is probably okay, but I wanted to make you aware of the above.
 
today's feeble attempt to support the empire
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic