Hey all I have one question I am new to GUI stuff so I need some help when I want to add an element to a window using some other method or if statement I don't get error but it doesn't show up hears a code I marked problem I am working in java by the way this is not whole program but only this is a problem
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Gui extends JFrame{
private JTextField usernameTF;
private JPasswordField passwordField;
private String username,password;
private JRadioButton A,B,C,D,F;
//private JComboBox box;
private JLabel logo,errorPic,promt;
private JButton logIn;
private boolean value;
private Apples function= new Apples();
public Gui(){
super ("Awsome Progrma");
setLayout(new FlowLayout());
Icon errorIcon = new ImageIcon(getClass().getResource("wrong.png"));
errorPic = new JLabel(errorIcon);
usernameTF = new JTextField(10);
usernameTF.setToolTipText("Enter your user name hear");
add(usernameTF);
passwordField = new JPasswordField(10);
passwordField.setToolTipText("Enter your password hear");
add(passwordField);
logIn = new JButton("Log IN");
add(logIn);
usernameTF.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent event){
username = event.getActionCommand();
password = passwordField.getText();
value = function.chack(username,password);
if (value == true){add(errorPic);} // this is a problem JLabel dosn't show up in my window
}
}
);
passwordField.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent event){
username = usernameTF.getText();;
password = event.getActionCommand();
value = function.chack(username,password);
if (value == true){add(errorPic);} // this is a problem JLabel dosn't show up in my window
}
}
);
logIn.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent event){
username = usernameTF.getText();
password = passwordField.getText();
value = function.chack(username,password);
if (value == true){add(errorPic);} // this is a problem JLabel dosn't show up in my window
}
}
);
}
}