LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-07-2006, 02:07 AM   #1
titanium_geek
Senior Member
 
Registered: May 2002
Location: Horsham Australia
Distribution: elementary os 5.1
Posts: 2,479

Rep: Reputation: 50
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

Last edited by titanium_geek; 05-07-2006 at 02:09 AM.
 
Old 05-07-2006, 02:19 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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

Last edited by paulsm4; 05-07-2006 at 02:22 AM.
 
Old 05-07-2006, 02:23 AM   #3
titanium_geek
Senior Member
 
Registered: May 2002
Location: Horsham Australia
Distribution: elementary os 5.1
Posts: 2,479

Original Poster
Rep: Reputation: 50
wow that was quick!

thanks a tonne- those links look cool!

titanium_geek
 
Old 05-07-2006, 02:25 AM   #4
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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
 
Old 05-07-2006, 06:33 AM   #5
titanium_geek
Senior Member
 
Registered: May 2002
Location: Horsham Australia
Distribution: elementary os 5.1
Posts: 2,479

Original Poster
Rep: Reputation: 50
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
 
  


Reply

Tags
input, java, output



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Input / Output Redirection made simple in Linux LXer Syndicated Linux News 0 01-06-2006 10:31 PM
wxPython GUI input/output simple question Hal Programming 0 04-14-2005 03:17 PM
Input / output error xviddivxoggmp3 Slackware 22 08-24-2004 12:47 PM
Input/output error Sn4s Linux - Hardware 6 07-26-2004 07:38 AM
input/output error c12ayon Linux - Newbie 2 12-27-2003 07:04 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration