Hi There.
Im doing a beginner project here in my studie.
So here is the thing.
I have a txt file, where there are words in different language.
The user must quess the word in his language and if he dosen´t know the word, he should search for it.
I´ve chosen a JOptionpane with selections, so the first words in the txt file appears, but i want to get
the other word that it points to out.
I have a controller:
public String lookup(String question){
for (Object value : data.values()) {
if (value.toString().startsWith(question)) {
//options.add((String) value);
return //want to return the the other word from text file on same line
(value.toString());//now it just returns the selected word
}
}
return null; // returner null if word dosen´t exists
}
private void jMenuItemLookupActionPerformed(java.awt.event.ActionEvent evt) {
//Her skal der søges på ordpar
Collection lData = Controller.data.values();
String var1 = (String) JOptionPane.showInputDialog(null, "Title", "Message", JOptionPane.QUESTION_MESSAGE,
null, lData.toArray(new String[] {}), lData.toArray()[0]);
String var2 = controller.lookup(var1);
JOptionPane.showMessageDialog(rootPane, var2);
System.out.println("Test" + var2);
}
Can someone help? In txt file it says ex.
Hund, Dog
and i want to get the last word out.
Or if someone have some tutorials on a site with selections with textfiles, just let me know.
Thanks
And the code for the GUI: