I'm using enums and JOptioPane, and I want to show the enum attribute, (I mean a string), this is what I have:
public Cities readCityOrigen() {
Cities [] listCityOrigen = Cities.values();
Cities city = (Cities) JOptionPane.showInputDialog(null,
"Seleccione la ciudad de origen del vuelo",
"CIUDAD DE ORIGEN", JOptionPane.QUESTION_MESSAGE,
null, listCityOrigen, listCityOrigen[0]);
return city;
}'
package models;
public enum Cities {
BOGOTA ("Bogota"),
CALI ("Cali"),
BUCARAMNAGA ("Bucaramanga"),
CARTAGENA("Cartagena"),
SANTA_MARTA("Santa Marta"),
MEDELLIN("Medellin"),
TUNJA("Tunja"),
PEREIRA("Pererira"),
ARMENIA("Armenia"),
RIOHACHA("Riohacha"),
TOKYO("Tokio"),
CARACAS("Caracas"),
PARIS("Paris"),
NEW_YORK("Nueva Yotk"),
MIAMI("Maimi"),
MADRID("Madrid");
String cities;
Cities(String cities){
this.cities = cities;
}
public String getCities(){
return this.cities;
}
}
I want the string to appear in the JOptionPane, but I get the attribute literal