Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

change password swing gui

public class TestPane extends JPanel {

    // This is cheat for demonstration purposes, please don't do this
    // in production
    private char[] password = "banana".toCharArray();

    public TestPane() {
        setLayout(new GridBagLayout());
        JButton btn = new JButton("Change password");
        btn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                ChangePasswordPane pane = new ChangePasswordPane();
                switch (JOptionPane.showConfirmDialog(TestPane.this, pane, "Change Password", JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION)) {
                    case JOptionPane.OK_OPTION:
                        char[] oldPassword = pane.getOldPassword();
                        if (Arrays.equals(password, oldPassword)) {
                            password = pane.getNewPassword();
                            JOptionPane.showMessageDialog(TestPane.this, "Password was changed");
                        } else {
                            JOptionPane.showMessageDialog(TestPane.this, "Password mismatch, your old password does not match your current password");
                        }
                        break;
                }
            }
        });

        add(btn);
    }

}
Comment

PREVIOUS NEXT
Code Example
Java :: records java final 
Java :: Encrypt words facebook 
Java :: get all colors in string spigot 
Java :: how to fetch email and get there body content in spring boot 
Java :: how to make jframe full screen 
Java :: treeset order in java 
Java :: textbox to arraylist 
Java :: java difrence betwen x++ and ++x 
Java :: class java 
Java :: why is write replacing my text java 
Java :: java unshift 
Java :: Example: My favorite cities 
Java :: kotlin dependency injection 
Java :: Which package contains the Math classin java? 
Java :: data base spring 
Java :: android conditional api level 
Java :: @android:color/system_neutral1_1000 
Java :: float division by zero 
Java :: Java Arraylist bestimmtes element ausgeben 
Java :: how to add a command to a button java 
Java :: venatana emergente con texto java 
Java :: java isalphanum 
Java :: java 8 retrieve all list from object into single list and ignore duplicates 
Java :: check if item lore is something bukkit 
Java :: java focus to desktop 
Java :: java structure 
Java :: hashtable 
Java :: java lambda function 
Java :: find repeated elements in array java 
Java :: add integers java 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =