Forums Login/signup

GUI flexibility

+Pie Number of slices to send: Send
Hello all,

Is it possible to make GUI control like Button as a container?

For example can I make four regions say left top,right top,left bottom,right bottom on a button, so if I click on left region area some action is fired
and different action is fired on different regions.

Can we make all controls to be displayed in all 360 degree direction? I mean can we rotate it?

Thanks,
Nikesh
+Pie Number of slices to send: Send
Tell us what is the requirement. So we can think of different solution
+Pie Number of slices to send: Send
Since JButton subclasses Container, the answer is yes, but it is going to confuse your users heavily. Why would you want to do it, when you got JPanel's?

Figuring out the click regions won't be that easy, effectively you will be clicking the same button every time. You will need to define the bounds for the top/left/bottom/right regions. Then you will need to trap the mouse clicks. Then you will need to get the co-ordinates for the click. Then you will need to figure out which region was clicked and process accordingly. Not worth the effort in my opinion.
Easier would be a JPanel with different buttons (or some suitable component) added using say BorderLayout (or any other suitable layout)

Graphics2D has a rotate method which you can use. Of course this would involve tweaking the paintComponent method.
+Pie Number of slices to send: Send
+Pie Number of slices to send: Send
The transformer demo is fun.
Thanks for sharing.
+Pie Number of slices to send: Send
Ya Great
+Pie Number of slices to send: Send
Thanks for sharing this demo. It's cool.

reply
reply
This thread has been viewed 1124 times.
Similar Threads
priniting module
Job position description
Swing problem, with examples
gui choices
priniting module
More...

All times above are in ranch (not your local) time.
The current ranch time is
Jun 28, 2025 00:11:46.