Auf Thema antworten

Hallo Java community,



Also schreibe ich  Java swing apps und das ist eine teil von dieses code. Ich habe hier Java textArea und "actionPerformed" für die Buttons. wenn ich clicke "addBtn" - Button, mochte ich neben text auch error icon mit Rote Farbe in der TextArea schreiben.

Vieleicht jemand hat idee wie kann ich zugreifen. Es wird sehr hilfreich fur mich.



Vielen dank


[code=Java]addBtn.addActionListener(new ActionListener() {


            @Override

            public void actionPerformed(ActionEvent arg0) {



                String name = nameField.getText();



                String password = passwordField.getText();



                String text = "";



                int length;

                length = password.length();



                if (length < 7 && name.equals("Ehemaster")) {



                    text = "Password is Right and username is Right";



                }



                if (password.equals("2004") && !name.equals("Ehemaster")) {



                    text = "Password is Right and username is wrong";

                }

                if (!password.equals("2004") && name.equals("Ehemaster")) {



                    text = "Password is Wrong and username is Right";

                }

                if (!password.equals("2004") && !name.equals("Ehemaster")) {



                    text = "Password is Wrong and username is Wrong";

                }

                if (password.equals("") && !name.equals("")) {



                    text = "Please insert username and Password ";

                }



                text += " \n" + "Username:" + name + "\n" + "Password:"

                        + password + "\n" + "\n";



                fireDetailEvent(new DetailEvent(this, text));



            }



        });[/code]



Oben