Option Pane went out of common use for keyboard input when Scanner was introduced in 2004. I am surprised that such old‑fashioned style should be a requirement.Jenn Tran wrote:. . . I have to use JOptionPane. . . .
Option Pane went out of common use for keyboard input when Scanner was introduced in 2004. I am surprised that such old‑fashioned style should be a requirement.
Campbell Ritchie wrote:I said that Scanner superseded option pane for keyboard input.
Jenn Tran wrote:it is 1 of the requirement that I have to use JOptionPane. so how would I do that and where would I put the try catch in? thanks
OP not creating a GUI application, he is taking the keyboard input with GUI component (I wouldn't call it a GUI for application), what Campbell said it is a old fashioned way to do so, and I think he is right. Try imagine you have an application window, and for the input pops out another window for input, once you provide the input, you get another window (showMessageDialog) with "thanks for input" message, and then another cycle, maybe third and fourth.. And in this way you keep closing the pop up windows till you forget what have you been asked to do initially.Brett Spell wrote:one wouldn't use Scanner in a GUI application as a substitute for JOptionPane
Liutauras Vilda wrote:OP not creating a GUI application, he is taking the keyboard input with GUI component (I wouldn't call it a GUI for application)
Liutauras Vilda wrote:Try imagine you have an application window, and for the input pops out another window for input...
I think we are actually saying the same thing but in such a way that we are confusing each other into thinking we disagree. When I said keyboard input I meant for a console application rather than a GUI.If that isn't crappy code my name isn't Campbell Ritchie.Brett Spell wrote:. . . That's not correct either. . . .
We know that, and have provided suggestions for code style which does use option pane. But you should regard option pane as obsolete for a command‑line application. The OP has been told something a bit like what I have never been told:-Brett Spell wrote:. . . using JOptionPane is a requirement. . . .
For any application which does not have a guaranteed console to provide input/output option pane remains in frequent use. If you have a non‑GUI app running from an executable .jar, option pane will probably be your favoured method for input and output.Fortunately, nobody ever wrote:Campbell, you need to go to London. You need to take the steam train to King's Cross.
Campbell Ritchie wrote:you should regard option pane as obsolete for a command line application.
...
If you have a non‑GUI app running from an executable .jar, option pane will probably be your favoured method for input and output.
Campbell Ritchie wrote:We seem to be in agreement that OP has unfortunately been required to use a less than optimal implementation.
I have to admit agree with this point fully.Brett Spell wrote:which is what most people think of as a software application
Campbell Ritchie wrote:Now, having "Hello, Brett" appear in an option pane would entail real OO programming
Brett Spell wrote:. . . A "Hello, Campbell!" would be at least as good.