Reputation: 747
I have a method that draws animated image on glass pane to simulate pulsing of an icon. It needs an image (i use icons of components) and bounds (of a button f.e.). I need this area:
I know that button has getBounds()
, does tabs have something similar? Or maybe coordinates of an Icon. Either would be nice.
Upvotes: 4
Views: 1237
Reputation: 1810
I had a similar problem. I needed height of tab. int tabHeight = myTabPanel.getUI().getTabBounds(myTabPanel, 0).height;
.
Upvotes: 5
Reputation: 324118
I know that button has getBounds(), does tabs have something similar?
See the getTabBounds()
method of BasicTabbedPaneUI
. You don't need to customize the class just to get this data. You only need to custom the UI if you intend to do the animation witin the UI.
The problem is that the size of the tab will just be the size of the text. So you won't have empty space for your icon unless you add an empty icon to the tab as well. If you are going to do this then you could use the Animatied Icon class which allows you to combine icons to perform animation.
Upvotes: 1
Reputation: 205785
@mKorbel is right about the UI delegate, but the effort is formidable. Alternatively, you may be able to leverage an animated icon, shown here, or a custom tab component, referenced here.
Upvotes: 2
Reputation: 109813
You have to create own BasicTabbedPaneUI, because these methods are protected and there no way to override these methods from outside, (that came from Standard Java API)
Upvotes: 2