Why does JComponent have add() and remove() methods but Component does not?



Why does JComponent have add() and remove() methods but Component does not?..

Answer / Meena Verma

JComponent is a subclass of Component in Swing, which is designed to provide common functionality for visual components. As such, it inherits some methods from its superclass (Component), including add() and remove(). However, Component itself does not have these methods because they are not relevant for all types of components. The add() method allows components to be added to a container, while the remove() method removes them. These methods are necessary for managing the hierarchy and layout of components within containers.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Swing Interview Questions

Is swing still used?

1 Answers  


what are the root classes of all classes?

4 Answers  


How to add and delete nodes in Jtree?

1 Answers   MindMill,


What are heavyweight components? What is lightweight component?

1 Answers  


Why swings are used in java?

1 Answers  


How to link two forms in java swing?

1 Answers  


please any one explain this project: Minimizing recovery state in geographic ad hoc routing

1 Answers   IBM,


In what context should the value of swing components be updated directly?

1 Answers  


What are the differences between Swing and AWT?

1 Answers  


What is the default look and feel of a Swing Component?

3 Answers  


How to perform action on button in java swing?

1 Answers  


How to reload a jframe in java swing?

1 Answers  


Categories