LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   simple input output java 1.4 (https://www.linuxquestions.org/questions/programming-9/simple-input-output-java-1-4-a-442394/)

titanium_geek 05-07-2006 02:07 AM

simple input output java 1.4
 
ok, here's my issue.

I am currently studying java programming at university (and loving it) but my mac, panther, won't run java 1.5. (grr apple)
a tiger upgrade just isn't feasible at the moment.

The biggest, most obvious problem is Scanner- a brilliant utility in java 1.5 but not usable for 1.4

ok. I can live with that, but how do I get simple user interaction? I'm thinking a simple gui with a text area and a text box, to replicate the console.

any pointers for api to read, tutorials, code etc? (I'm cool with setting up the gui, just not how to get user input etc)

this is for homework, but in a roundabout way- this is so I can do my coding at home, instead of in the uni labs.

thanks!

titanium_geek

paulsm4 05-07-2006 02:19 AM

Hi -

JOptionPane sounds like it might be what you're looking for. Here's some sample code:
http://www.ensta.fr/~diam/java/onlin...ple-input.html
http://www.cs.usm.maine.edu/~welty/c...OptionPane.htm
Code:

  public static void main (String[] args)
      {
          String message;

          //  Get the message.
          message =JOptionPane.showInputDialog("Enter a line of text:");

          //  Display the message.
          JOptionPane.showMessageDialog(null,
                    message,
                  "Your message",
                  JOptionPane.INFORMATION_MESSAGE);

          System.exit(0);
      }

Here's an equivalent to "fgets()" in Java:

http://en.wikibooks.org/wiki/Program...put_and_output
http://www.rgagnon.com/javadetails/java-0053.html

Code:

public String readLine()
{      BufferedReader x = new BufferedReader(new InputStreamReader(System.in));        //Creates a new BufferedReader object
        return x.readLine();                                                            //Reads a line of input and returns it directly
}

'Hope that helps .. PSM

titanium_geek 05-07-2006 02:23 AM

wow that was quick!

thanks a tonne- those links look cool!

titanium_geek

paulsm4 05-07-2006 02:25 AM

Hi -

My pleasure.

I'm surprised to hear that JDK 1.5 isn't available for MacOS!

And good luck with your class!

PS:
One more site that might be of interest to you:

http://www.javaranch.com

titanium_geek 05-07-2006 06:33 AM

jdk 1.5 is available for macOSX 10.4 (tiger) but not for 10.3 (panther) and I not coughing up to upgrade because it still all works, it's just the java that is the issue.

thanks again, those links look good.

titanium_geek


All times are GMT -5. The time now is 06:44 AM.