GeeCON Prague 2014*
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


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.
 
GeeCON Prague 2014
 
subject: How to use custom class in frame