This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes How to use custom class in frame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to use custom class in frame" Watch "How to use custom class in frame" New topic
Author

How to use custom class in frame

juniad Ahmed
Greenhorn

Joined: Feb 19, 2011
Posts: 24
Hi Guys,

I was trying to write all button in one java class which extends component and use that object in my main class, But its not displaying those buttons. I have to use AWT and not swings. Please help

Maroun Baydoun
Greenhorn

Joined: Sep 23, 2011
Posts: 4

Hi,

The problem is the the Panel p you're creating in ButtonMenu is not being added to any container, therefore it won't be showing.

Here's one solution to that problem:



This way, ButtonMenu becomes itself a Panel, and the buttons will be added directly into it, so when when you add an instance of ButtonMenu inside of a Frame the buttons will show
juniad Ahmed
Greenhorn

Joined: Feb 19, 2011
Posts: 24
Thanks Maroun Baydoun. It worked like a charm.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to use custom class in frame
 
Similar Threads
Text canvas vertical scroll
How can I display an image on an AWT panel
Trying to load an image and modifying it....
Auto Maximise GUI
Register Event Listener to Button?