Reputation: 278
I am starting of with Java desktop app development after having started with Android Development first (a little curious, but there it is).
What I have done is to create a Class title Login.java
which is where the app should start and it does. After authenticating comparing with a MySQL Database table, I need to show a new Class titled Members.java
.
To that effect, I tried the solution from here: Java swing application, close one window and open another when button is clicked and used this code in my Login.java
file:
dispose();
new Members().setVisible(true);
What is happening however is, the Login.java
window closes briefly (sort of) and then shows the Members.java
. Is this behavior normal? Or am I coding it wrong? The Members.java
needs to replace the Login.java
after authentication.
Let me draw a quick comparison with Android to clarify a little further (in case the above does not). When I need to show a new class in Android
, I can call it by firing a simple code such as this:
Intent showActivity = new Intent(this, SecondActivity.class);
startActivity(showActivity);
This does not give the impression that something closed and then something opened. Any help is appreciated.
P.S.: I tried searching a lot, but since I am not sure what to search for, it's been a no go on that front. Also, I am using Netbeans as my IDE as against Eclipse.
Upvotes: 2
Views: 3845
Reputation: 13960
What is happening however is, the Login.java window closes briefly (sort of) and then shows the Members.java. Is this behavior normal?
Of course, that's exactly what you requested.
dispose(); // close the Login window
new Members().setVisible(true); // and show another window
If you want to get rid of that brief pause, call dispose
after new Members().setVisible
.
Upvotes: 3