aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes GUI flexibility Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "GUI flexibility" Watch "GUI flexibility" New topic
Author

GUI flexibility

Nikes Shah
Ranch Hand

Joined: Jul 18, 2007
Posts: 133
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
Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 290

Tell us what is the requirement. So we can think of different solution


-Chiru
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10523
    
    9

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.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Dmitry Mamonov
Greenhorn

Joined: Dec 24, 2008
Posts: 28
Try this: https://swinghelper.dev.java.net/bin/transformer/TransformerDemo.jnlp
at https://swinghelper.dev.java.net/
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10523
    
    9

The transformer demo is fun.
Thanks for sharing.
Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 290

Ya Great
Nikes Shah
Ranch Hand

Joined: Jul 18, 2007
Posts: 133
Thanks for sharing this demo. It's cool.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GUI flexibility