Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Gui inheritance Question Using NetBeans

Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Frame that I inherited from JFrame Class. I have placed a couple of Buttons on that frame I will call this frame aFrame.

Now what I want to do is inherit from the new aFrame class which has the buttons already placed on the frame. I could not find a way in the netbeans ide to specify that I wanted the superclass to be the frame with the buttons already on it.I create a new frame class and change the generated code to extend the aFrame class. When I open that class in the GUI designer I cannot see the buttons but if I run the app and open the new frame the buttons are there and visible.

My questions are as follows.
1. Am I correct in assuming that if I inherit from a Frame object it should contain the buttons which it does but should they be visible when I open the "new" Frame? I am coming from another visual development language which works in this way.

2. I know that this is not a NetBeans forum but does anybody know is there a correct way in the NetBeans GUI to specify a class to extend that allows the buttons to be visible in the class that is extending another Frame?

Posts: 70349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Not quite sure about either half of your query, but try this:-
  • If you call your class AFrame, you need another class which extends it.
  • Create class BFrame extends AFrame.
  • Create BFrame constructor with String title as its parameter.
  • Call super(title); in the BFrame constructor.
  • Add any other features you need.

  • I don't use NetBeans very often, preferring Eclipse, but I can't remember a simple way of naming a superclass in the NetBeans new class wizard. There is a "superclass" box and an "interfaces" box in the corresponding wizard in Eclipse, which I use all the time. You might have to do it the hard way, writing "class BFrame extends AFrame."

    Ranch Hand
    Posts: 107
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Jim!

    As a fellow Netbeans user, I have fought this before. In order to get your subclass to show up correctly in the form designer, you must create a javabean containing the component, and then install that bean into the Pallet. After that, you can drag-and-drop the item from the Pallet onto a form, and all should be well. If you are using Netbeans 5.5, there is an easier way using a project, but a better description of the process can be found here:

    Good luck!

    Been there. Done that. Went back for more. But this time, I took this tiny ad with me:
    the value of filler advertising in 2020
      Bookmark Topic Watch Topic
    • New Topic