Hi All!!
I'm new in this forum. My name is Mauro and i'm italian, so... sorry for my english >_<
The question of this post is:
My professor wants us to not use JOptionPane to display inputdialog, and he wants us to create a small window where you can enter for example the name of a file to open and/or load.
So what did I do, I create a class, i implemented ActionListener listeners for events and extend the class with JFrame, and in the constructor I build my beautiful window. So far so good, it creates, and I can manage it completely.
Now comes the fun part.
If I put in the main by, for example:
the program of course, continue to run the underlying code, without stopping to wait for me to insert a given value in the JTextField.IG_MiniFrame frmCorridoi = new IG_MiniFrame("Numero Corridoi!", 300, 200, 260, 100, "Numero Corridoi:"); IG_MiniFrame frmFile = new IG_MiniFrame("Numero File!", 300, 200, 260, 100, "Numero File:"); IG_MiniFrame frmPosti = new IG_MiniFrame("Numero Posti!", 300, 200, 260, 100, "Numero Posti:");
I remedied this with a horrid, ugly, that goes against my way of programming, but I only found this method, and that is to put a while loop that loops until I press the OK button of the window that I change a Boolean variable to true and will continue the main and open another window:
What I ask is: is there a more "beautiful" to program such a thing? lock code until you enter the value in the text?IG_MiniFrame frmCorridoi = new IG_MiniFrame("Numero Corridoi!", 300, 200, 260, 100, "Numero Corridoi:"); while(frmCorridoi.getComplete()==false){} IG_MiniFrame frmFile = new IG_MiniFrame("Numero File!", 300, 200, 260, 100, "Numero File:"); while(frmFile.getComplete()==false){} IG_MiniFrame frmPosti = new IG_MiniFrame("Numero Posti!", 300, 200, 260, 100, "Numero Posti:"); while(frmPosti.getComplete()==false){}
It would take a good method in the actionperformed type:
main.continue(); XD
and of course in the constructor main.stop(); >_>