Results 1 to 18 of 18
Thread: how to get only one "ok" window!
- 06-21-2010, 11:20 PM #1
Member
- Join Date
- Jun 2010
- Posts
- 9
- Rep Power
- 0
how to get only one "ok" window!
hi
i'm new to java, and i want to ask a bizarre question! :D
i'm using a program that generates some files, for example 5 files, the problem that in the program i must clic on "ok" message to generate the second file; ie: the program waits till i'll clic on 'ok' to increment the loop (for)....
is it a way to make this to have only ONE OK?
i've tried a hack, is by using a loop, (N-1) that makes as i pressed "Enter" and the the latest N will be the latest 'ok' that the user will push .... but as am beginner i can't code it lool
but, is it a way to make this "ok" appear only once a time?
i use JCreator LE.
thanks in advance :cool:
- 06-21-2010, 11:25 PM #2
erm
put the ok message in an if statment so that in only runs once the loop has finished.Teaching myself java so that i can eventually join the industry! Started in June 2010
- 06-21-2010, 11:28 PM #3
Member
- Join Date
- Jun 2010
- Posts
- 9
- Rep Power
- 0
thank you alacn
but the problem, with the if statement, there is no condition to make the break, i've thaught about this, is to make some thing to make the loop exit and go directly to the ok message....
but with the for we have a number of file "parsing" and a number of generated files, so i think the for is the loop that is needed?
- 06-21-2010, 11:33 PM #4
can you post your code please
and yeah i would use a for loop to loop through all files and then use the counter viarable to check once the last file in the loop has been reach with an if statment, then display the message.Teaching myself java so that i can eventually join the industry! Started in June 2010
- 06-21-2010, 11:36 PM #5
Senior Member
- Join Date
- May 2010
- Posts
- 436
- Rep Power
- 4
The simplest solution (if I understand your problem correctly) is to use a JOptionPane for your OK button. As a modal dialog it should halt Swing actions until it has been dealt with.
If this doesn't answer your question, you may need to give more detail.
- 06-21-2010, 11:40 PM #6
Member
- Join Date
- Jun 2010
- Posts
- 9
- Rep Power
- 0
thank you alacn, i think it's a good idea, i'll give it a try :D
thank you curmudgeon, here i've not the entire code, it is on the other computer, tomorrow i'll test it and i'll give you the answer and more details :)
thank you again for helping me :)
- 06-23-2010, 12:02 AM #7
Member
- Join Date
- Jun 2010
- Posts
- 9
- Rep Power
- 0
hi,
here i'm again :D
about the "JOptionPane" instruction, i used it, but it's the same problem!!!
the program waits till i press ok to continue working in the loop! i want to continue the loop without waiting to press ok :(
is it possible :(
is there any instruction to tell java to do this:
generates all file and then show the ok dialog (and not every time you generate a file you show me the ok message and you wait till i press ok to generate the second one)
- 06-23-2010, 12:10 AM #8
What then is the purpose of asking the question if the loop is to continue without the answer?i want to continue the loop without waiting to press ok
- 06-23-2010, 12:16 AM #9
Member
- Join Date
- Jun 2010
- Posts
- 9
- Rep Power
- 0
hi :D
the problem is that the program will generate some files, it parses xml files and generates other files, so if you have 5 files, it will generate 5 other files, and of course it will display 5 ok messages, so imagine the user wants to parse 1000 xml!!!! so he must stay near to the screen clicking every time on ok :eek:
- 06-23-2010, 12:18 AM #10
Why ask any questions at all?
Or only one before starting?
- 06-23-2010, 12:20 AM #11
Member
- Join Date
- Jun 2010
- Posts
- 9
- Rep Power
- 0
heuuuuuuuuu????????????
sorry, but i dont understand here...which question?
- 06-23-2010, 12:28 AM #12
The question the prompt asks: Is it OK to ...
Another idea:
The JOptionPane has several different formats for display info and asking questions. One of them allows you to get different answers to your question.
You could ask the user if its OK to do one more or if its OK to do ALL of the rest. If the user says ALL of the rest, you set a boolean to remember that and do NOT ask again.
- 06-23-2010, 07:01 PM #13
Senior Member
- Join Date
- Mar 2009
- Posts
- 552
- Rep Power
- 5
Code is good... really helps us more than you explaining ever will :P
Anyway, why not put the loop in its own method, and use JOptionPane before calling that method? Pseudocode...
hopefully this helps :DJava Code:method that starts process (confirmAndCreate): show JOptionPane to confirm if ok was clicked then: call createFiles else return method that creates files (createFiles): for file in filesToParse parse file create new file(s) returnIf the above doesn't make sense to you, ignore it, but remember it - might be useful!
And if you just randomly taught yourself to program, well... you're just like me!
- 06-23-2010, 10:57 PM #14
Member
- Join Date
- Jun 2010
- Posts
- 9
- Rep Power
- 0
thank you, and sorry if i took long time to reply, i opologize :o
thanks for the idea, but the problem is that (or we, because am not the only one on the project) are beginners in java coding!!! so how do i put the boolean?
heuuuuuuuuuuuu!!!!
thanks for the code!!!
i'll try it tomorrow because the entire code is not with me, i'll try it and give the answer tomorrow :)
thanks again for the help :D
- 06-24-2010, 12:51 AM #15
pseudo code:
Java Code:boolean askQues = true; // boolean to control whether to ask user the question Begin loop for writing files { if(askQues) { Ask question to user: Ok to write one or all or ??? if (response == OK to write all) askQues = false; // remember to not ask this question again .. handle other possible responses } ... create and write file } // end loop for creating and writing files
- 06-24-2010, 06:20 AM #16
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
If my answer helped you. Please click my "REP" button and add a comment
Have a Good Java Coding :)
- 06-24-2010, 11:08 PM #17
Member
- Join Date
- Jun 2010
- Posts
- 9
- Rep Power
- 0
thank you !!! really thanks for the help!!!
thank you, i'll try the code, and as i said am not the real coder, so i must give the code the the coder to test it!!! in java am dumb :(
we tried to put the ok dialog at the end of the loop but it dident work! it generated only one file!!!! bizarre! :eek:
thank's for the code, we'll try this!! maybe it will work :cool: (and am sure it will do) :DLast edited by abdoubb; 06-24-2010 at 11:14 PM.
- 07-01-2010, 12:04 AM #18
Member
- Join Date
- Jun 2010
- Posts
- 9
- Rep Power
- 0
Similar Threads
-
Java, Military Format using "/" and "%" Operator!!
By sk8rsam77 in forum New To JavaReplies: 11Last Post: 02-26-2010, 03:03 AM -
How to change my form design from "metal" to "nimbus" in Netbeans 6.7.1?
By mlibot in forum New To JavaReplies: 1Last Post: 01-21-2010, 09:20 AM -
problem with argument list and precedence "(" and ")"
By helpisontheway in forum Advanced JavaReplies: 6Last Post: 12-24-2009, 07:50 AM -
MoneyOut.println("It took you (whats wrong?>",year,"<WW?) years to repay the loan")
By soc86 in forum New To JavaReplies: 2Last Post: 01-24-2009, 06:56 PM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 07:35 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks