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

Panel to acts like Button

Anil Patil
Greenhorn

Joined: Oct 20, 2008
Posts: 2
I wanted to create Panel which will acts like a button.
Like
In panel i ll use labels and textbox, and whole panel should have property of button.

Or in Button, it is possible to put labels and text area
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39869
    
  28
Yes, it is possible to add a text box to a button. Or you can use extends. Or you can have a button occupying the whole of a panel, and set the button to be transparent.

But all those suggestions appear bad design to me; a button is a button, not a text box, and a panel is a panel, not a button.
Anil Patil
Greenhorn

Joined: Oct 20, 2008
Posts: 2
Hi Ritchie,

Thanks for suggestion, But my requirements are specific.

Can you elaborate more how can add Labels in button, as I am new to Swings/AWT components
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4658
    
    5

JComponent extends Container, so all JComponent subclasses including JButton can be used (or abused) as a container.

I am new to Swings/AWT components

Recommended reading: The Java� Tutorials : Creating a GUI with JFC/Swing


luck, db
There are no new questions, but there may be new answers.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Also good reading:

http://faq.javaranch.com/java/SwingIsAProperNoun


GenRocket - Experts at Building Test Data
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Panel to acts like Button