Got it, thanks :) I had to use reflection to get the correct argument
for tabPane.remove(), does it look right to you?
tabPane.getComponentMouseButtonListeners().add(new
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 =
TerraTabPaneSkin.TabButton.class.getDeclaredField("tab");
tabField.setAccessible(true);
tabPane.getTabs().remove((Component)
tabField.get(descendant));
} 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