Ad Code

✨🎆 Diwali Dhamaka Offer! 🎆✨

Get 20% OFF on All Courses at Shiva Concept Solution click

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();
           obj.setVisible(true);
        }
        else
        {
            JOptionPane.showMessageDialog(null, "Invalid Userid and password");
        }
    }   

Post a Comment

0 Comments