Skip to main content

Detect a click on JTaskPane's title

2 replies [Last post]
Joined: 2010-01-27
Points: 0

Hello everybody !

I want to use the JTaskPane in my application and I want to know if it is possible to know when a user has clicked on the title of the JTaskPane ?

And, is it possible to expand the JTaskPane only if the user has clicked on the arrow icon and not in the title of the JTaskPane ?

Thanks a lot for your answer.


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-06-11
Points: 0

first question: nothing out of the box - the title area is actually part of a border. You have to implement it yourself: register a mouseListener and check if the event happens inside the title area (titleHeight is the property to check against)

second question: hmm .. don't think so. Why would you want that - standard behaviour of such components is to expand/collapse on clicking anywhere. The icon is just a decoration to visualize the current state.


Joined: 2010-01-27
Points: 0

Hi Jeanette, thanks for your answer.

1) Thanks you :)

2) You're right. I want to use this component in (probably) a non standard way. Each JTaskPane should be related to what the application is displaying, they have a title and one or several actions.
The way I want to use it is much like a "super JButton" which provide a default action and others which will be secondary actions, or shorcuts.

Currently in my application I'm using JButtons displayed as a vertical stack in a JPanel which is displayed on the left of the screen.
For example, I have a JButton which display a diary, its text property is "Diary".
If the user wants to add an entry to its diary he has to click on "Diary" and do another click on the "add an entry" button which is located on my "Diary Panel".
So they have to do 2 clicks, and the first one loads and display a diary component which is heavy and a bit long to display (one or two seconds).

With a JTaskPane I want to keep this behaviour of displaying the diary if the user click on the JTaskPane's title, but add some shortcuts actions in it like "add a entry" which enable the user to add an entry without having to load and display the whole panel.
And I think in this use case I think that expand the component is not an expected behaviour because it does 2 things at the same time.