Solution to a probleme to access to a panel in Java?

31 Views Asked by At

I have implemented a chat application in which the first panel would be displayed is the WelcomePanel, and as the child Panels there is one which have i called LoginPanel where the user must log on to chat, i looked after errors in my code and i have'nt noticed any. Can you help me? there is the code(Made in the Eclipse IDE) Notice:i've made in all the parts the try catch block in order to detect the error and all of them are displayed during the execution of the program

private void addEventsForLoginPanel() {
    try {

    loginPanel.getTfNickname().addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent ke) {
            if(ke.getKeyCode() == KeyEvent.VK_ENTER) {//KeyEvent.VK_ENTER to simulate the click on the button ok
                btOkEvent();
                }
        }

    });}catch(Exception e) {
        System.out.println("error in part 1");
        }

    try {
    loginPanel.getTfPass().addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent ke) {
            if(ke.getKeyCode() == KeyEvent.VK_ENTER) {
                btOkEvent();
                }
        }

    });}catch(Exception e) {
        System.out.println("error in part 2");
        }

    try {
    loginPanel.getBtOK().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            btOkEvent();
        }
    });}catch(Exception e) {
        System.out.println("error in part 3");
        }
    try {
    loginPanel.getLbBack_login().addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent me) {
            welcomePanel.setVisible(true);
            signUpPanel.setVisible(false);
            loginPanel.setVisible(false);
            clientPanel.setVisible(false);
            roomPanel.setVisible(false);
        }
    });
    }catch(Exception e) {
        System.out.println("error in part 4");
        }
    }

Thank you for your help

0

There are 0 best solutions below