Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to use custom class in frame  RSS feed

 
juniad Ahmed
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
Java jQuery Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Maroun Baydoun. It worked like a charm.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!