How to get tab header coordinates in jTabbedPane?

I have a method that draws an animated image on glass glass to simulate the pulsation of an icon. He needs an image (I use component icons) and borders (fe buttons). I need this area:

enter image description here

I know the button has getBounds() , does the tabs have something similar? Or maybe the coordinates of the icon . Or it would be good.

+4
source share
4 answers

You need to create your own BasicTabbedPaneUI because these methods are protected and there is no way to override these methods from the outside (this came from the Standard Java API )

+3
source

I had a similar problem. I need a tab height. int tabHeight = myTabPanel.getUI().getTabBounds(myTabPanel, 0).height; .

+5
source

@mKorbel is right about the UI delegate, but the effort is huge. Alternatively, you can use the animated icon shown here , or the custom tab component that is referenced here .

+3
source

I know the button has getBounds (), does the tabs have something similar?

See the getTabBounds() BasicTabbedPaneUI . You do not need to configure the class just to get this data. You only need to customize the user interface if you intend to do animation with the user interface.

The problem is that the size of the tab will be just the size of the text. This way, you will not have empty space for your icon unless you add a blank icon to the tab. If you intend to do this, you can use the Animatied Icon class, which allows you to combine icons to perform animations.

+1
source

Source: https://habr.com/ru/post/1388276/


All Articles