• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Panel to acts like Button

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also good reading:

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