Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 17th, 2007, 07:23 PM
Registered User
Join Date: Oct 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default result line break.

Hello there. I am in a java programming class at my school and we needed to make a program that takes Meters/sec and converts it into Miles/hour, as well as feet/sec converting it into the same thing. I know how to do the math fine and I get the results up fine and everything. My problem is my results don't fit on the screen. Its just one bit line that goes off the form, I can make the form bigger to show everything, but that seems roundabout. I want to know if there is a command that will break up my results and move them to new lines. I tried using /n and /r, but they did now work. This is my first time here, so I don't know if I need to put in the entire code or not, so here is just part of it.

// Get values used in calculation
fps = Integer.parseInt(fpsField.getText());
mps = Integer.parseInt(mpsField.getText());

// Do calculations
mph = fps * 60 * 60 / 5280;
mphh = mps * 3 * 60 * 60 / 5280;

// Provide user with result of calculation
outputLabel.setText("Your Speed in MPH from FPS is " + mph + "And your speed from Meter/sec is " + mphh);
It prints my results on one line and I want to break it where it starts, "And your...." Any help would be great. Thanks

Old October 18th, 2007, 05:28 AM
Friend of Wrox
Join Date: Dec 2003
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts

Erm if OutputLabel is a swing JLabel, you can use <br>


Charlie Harvey's website - linux, perl, java, anarchism and punk rock: http://charlieharvey.org.uk

Similar Threads
Thread Thread Starter Forum Replies Last Post
line break Cyber Shiva HTML Code Clinic 1 May 17th, 2007 06:04 AM
line break on email sent Maxxim BOOK: ASP.NET Website Programming Problem-Design-Solution 2 September 4th, 2006 04:07 PM
line break problem XSLT 1 February 20th, 2006 11:18 AM
Extra line Break kanchan_b XSLT 1 February 3rd, 2006 09:11 AM
break up line crmpicco Javascript How-To 1 June 6th, 2005 06:54 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.