Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Component.show() / hide() are deprecated ... why?

Does anyone know the reason why these Java swing methods are deprecated :

Component.show(); 
Component.hide();
like image 859
user43685 Avatar asked Mar 11 '09 21:03

user43685


People also ask

What does @component do in Java?

@Component is an annotation that allows Spring to automatically detect our custom beans. In other words, without having to write any explicit code, Spring will: Scan our application for classes annotated with @Component. Instantiate them and inject any specified dependencies into them.

Which model is used to provide actions to AWT components?

4) AWT is used for GUI programming in java? It is lightweight. It supports pluggable look and feel. It follows MVC (Model View Controller) architecture.


1 Answers

JDK 1.1 introduced Java Beans. Java Beans rely in reflection and introspection to determine what the properties of a Bean are (a Bean is a "component"). Properties are then displayed in a Property Sheet.

By default beans use the following foormat:

boolean isXXX()
<type> getXXX()
void setXXX(<type>)

(going from memory on these next two... they are for indexed properties)

<type> getXXX(int)
void setXXX(<type>, int)

You can override the defaults, but rather than do that most things just rely on the naming pattern.

So show/hide didn't conform to the naming pattern and were replaced with setVisible(boolean) which did.

like image 193
TofuBeer Avatar answered Sep 25 '22 14:09

TofuBeer