pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Edvin Syse <ed...@sysedata.no>
Subject Re: How to make middle mousebutton close a closable tab in a TabPane?
Date Fri, 13 May 2011 11:52:15 GMT
Got it, thanks :) I had to use reflection to get the correct argument 
for tabPane.remove(), does it look right to you?

ComponentMouseButtonListener.Adapter() {
             public boolean mouseClick(Component component, Mouse.Button 
button, int x, int y, int count) {
                 Component descendant = tabPane.getDescendantAt(x, y);
                 if (descendant instanceof TerraTabPaneSkin.TabButton && 
button == Mouse.Button.MIDDLE) {
                     try {
                         Field tabField = 
                     } catch (Exception ignored) {
                 return false;

Den 13.05.2011 13:34, skrev Greg Brown:
> Since the buttons are effectively private to the tab pane's skin, the "right" way to
do this would probably be to create a custom subclass of TerraTabPaneSkin that knows about
the buttons and can attach a listener to them. However, you could probably hack support for
this by registering a mouse listener on the TabPane itself, then calling tabPane.getComponentAt(x,
y). If the component is an instance of TerraTabPaneSkin.TabButton, then the user has clicked
on the tab button.
> On May 13, 2011, at 2:53 AM, Edvin Syse wrote:
>> I would like a middle mousebutton click to close the active tab in a TabPane, using
the same action that happens when one click the X in the tab. Where should I attach a listener
to make this happen?
>> -- Edvin

View raw message