Friday, October 17, 2014

JavaFX workaround for rotate text on tabpane tab

I have not much of experience with JavaFX, but I've been using it since almost over a year by now. I found that the tabs from the tabpane control have a restriction, when they are placed by a side either right or left the text can not be placed horizontal, the following image shows the behavior.


The issue is that the text is not displayed horizontally and it is hard to read, and javaFX does not provide a solution to it, actually there is feature request to it https://javafx-jira.kenai.com/browse/RT-19547 but it seems that it will not happen soon.

I found some workarounds to it, but they have many issues such as the text doesn't properly resize the tab width, so I'm going to describe the workaround that I did, hoping that it could be helpful to you.

A solution that I found from this post http://stackoverflow.com/questions/16708578/javafx-2-0-tabpane-tabs-at-left-and-keep-tab-header-horizontal , mentions to add the following style:

Which works fine:

But what if you have multiple tabs in your application and this tabs do not have the tabs by a side, it will also rotate the text of this tabs and will complicate everything.


Another issue is, if the characters of the text increases the size also increases but not only its width but also its height:


Due to all this issues this workaround and others seem to work fine only in certain scenarios.
My workaround is not better than them, but it tries to avoid these issues.
First, only rotate the tabs you want to rotate, to do this create a CSS class:



Then add it to the tabs objects you want to rotate:



Then create a CSS class to handle the size for the TabPane in which you are rotating the tabs:

Add this class to the TabPane object:

With this you will restrict the size of your tabs and they will not get bigger if the text increases. The limitation it has is that the amount of characters depends on the size you set to the TabPane object.




As I said I'm not an expert on javaFX and I found this solution to this issue that seems to be different to others and might help you.
If you have a different solution before this issue is fixed tell me about it.



13 comments:

  1. I am looking for some good blog sites for studying. I was searching over search engines and found your blog site on Nmims solved assignment

    ReplyDelete
  2. Keep doing this work this blog has everything I was looking for also check out this one Best Gynecologist In Faridabad thank you for this amazing post

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. My friend told me about your post. I really liked it. So let me also share with you that nowadays it is not at all necessary to spend time proofreading all your articles, as you can easily check sentences online using sentence identifier tools. and easily correct grammar and punctuation errors

    ReplyDelete
  5. Keep doing this work it really helps me to understand new things also check out this Best IVF Services in Delhi thank you for this wonderful post.

    ReplyDelete
  6. Dallas SEO Marketing refers to the practice of optimizing websites and online content to improve their visibility and rankings on search engine results pages (SERPs) in the Dallas, Texas area. It involves a combination of techniques and strategies, such as keyword research, on-page optimization, link building, and content creation, all tailored specifically to target local audiences in Dallas. By implementing effective SEO marketing strategies, businesses in Dallas can increase their online visibility, attract more targeted traffic to their websites, and ultimately drive more leads and conversions.

    ReplyDelete
  7. What a wonderful blog it contains some interesting topics and help me a lot in many ways keep doing this work also have a look on this Best neurologist in Faridabad

    ReplyDelete
  8. I'm searching for some great blog destinations for examining. I was looking through over web search tools and found your blog webpage on Amity project report

    ReplyDelete
  9. Thanks for sharing informative post, Lets find more informative blog.
    Give a chance to work with us.
    Learn more - Best Gynecologist in South Delhi

    ReplyDelete
  10. Well Done, Exciting blog, I really impressed with you blog, keep writing more interesting blog. Let's connect now. Best laparoscopic surgeon in delhi

    ReplyDelete
  11. Thank you for this post it really helps me a lot and contains some interesting topics keep doing this work also have a look at this Infertility Treatment In Faridabad

    ReplyDelete
  12. This article provides clear and comprehensive guidance on how to start an online food ordering and delivery business. The step-by-step approach, practical tips, and relevant examples make it a valuable resource for anyone considering entering the food delivery industry. A must-read for entrepreneurs looking to launch a successful online food business!

    ReplyDelete