Navigation in Swing Frame in Java


How to navigate from one frame to another in Swing?
To navigate from one frame to another we will create Object of Destination frame and call setVisible().
Code for Navigation:-
1 Create Login Jframe with this design screen

2) Create Another JFrame Dashboard Frame

3) Write Code on Login JFrame Button
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                       
        if(jTextField1.getText().toString().equals("admin") && jPasswordField1.getText().toString().equals("12345"))
            //new Dashboard().setVisible(true);
           Dashboard Obj = new Dashboard();
            JOptionPane.showMessageDialog(null, "Invalid Userid and password");

Post a Comment


POST Answer of Questions and ASK to Doubt

Post a Comment (0)