I am making a Repository Client for my sites repositories and I need to be able to detect when a user enters a certain id to detect which URL Repository to get it from.
Here is my code:
JTextField repo = new JTextField();
JButton submit = new JButton("Download!");
String repod = repo.getText();
final String repoid = repod;
submit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
if(repoid.equals("pb")){
//this
}else if(repoid.equals("mb")){
//this
}else if(repoid.equals("repo29-update")){
//this
}else{
System.out.println("Contacting SERVER...");
System.out.println("Finding REPOID: "+repoid);
System.out.println("Not Found! Returning Error!");
JLabel err = new JLabel("Invalid REPOID");
JFrame a = new JFrame("Error");
a.setSize(300,100);
a.setLocationRelativeTo(null);
a.setResizable(false);
a.setAlwaysOnTop(true);
a.add(err);
a.setVisible(true);
}
}
});
When I go through this script, I always get the else option, why?
This is not a duplicate, I changed the == to .equals() and it still doesnt work.