• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Panel to acts like Button

 
Anil Patil
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49796
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also good reading:

http://faq.javaranch.com/java/SwingIsAProperNoun
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic