• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JOptionpane removes more spaces present in the message??

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am trying to display the below information using JOptionepane.showMessageDialog();

=======================================================
Scroll exit swirl velocity factor = 1.1000
Impeller friction loss factor = 5.0000
Impeller incidence loss factor = 1.0000
Impeller pressure loss factor = 0.0300
Bearing loss factor = 1.7500
=======================================================
But when I display it using JOptionapane.showMessageDialog() it shows like this,
=======================================================
Scroll exit swirl velocity factor = 1.1000
Impeller friction loss factor = 5.0000
Impeller incidence loss factor = 1.0000
Impeller pressure loss factor = 0.0300
Bearing loss factor = 1.7500
=======================================================

why it is removing the spaces??
Is there any way to tell Joptionpane not to remove the spapces in message displayed??

Please help me out.
 
Praveen Kumar Jayaram
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry even this site is removing the spaces that I intended to show you guys in the previous message.

Same thing is happening in JOptionpane..
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Praveen Kumar Jayaram:
Sorry even this site is removing the spaces that I intended to show you guys in the previous message.

Same thing is happening in JOptionpane..



Try wrapping it inside HTML so you can control the spaces and formatting.
 
Praveen Kumar Jayaram
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to wrap it properly?

It is showing like this: "<html><body>contents here</body></html>"

It is showing the tags too.
Please suggest how to go about.

Thanks in advance.
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Praveen Kumar Jayaram:
How to wrap it properly?



JOptionPane.showXXX accepts Objects as messages.
Since JLabel supports HTML, you can construct a JLabel with your HTML formatted message and then pass this label to the JOptionPane.
 
Praveen Kumar Jayaram
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your suggestions.

I tried creating a JLabel instance with "<html><body>contents here</body></html>" and passing it to JOptionpane.showMessageDialog().

Even though it is same thing is happening.

Here is my code:
===================================================================
File outFile = new File(outFileNameWithoutExt+".OUT");
read = new FileReader(outFile);
buffRead = new BufferedReader(read);
//read first line from .OUT file
String str = buffRead.readLine().trim();

//read and discard .OUT file data until we find "CALCULATED GEOMETRY"
while(!str.equalsIgnoreCase("CALCULATED GEOMETRY"))
{
//read the subsequent line from .OUT file
str = buffRead.readLine().trim();
}
//read and discard the empty line
buffRead.readLine();
StringBuffer calculatedGeometry = new StringBuffer();
//read first line in calculated geometry info
str = buffRead.readLine();
//read until we find an empty line
while(!str.isEmpty())
{
//append the calculated geometry info and new line character
calculatedGeometry.append(str+"<br>");
//read next line
str = buffRead.readLine();
}

//display the calculated geometry info
JLabel jbl = new JLabel("<html><body>"+"CALCULATED GEOMETRY :<br><br>"+calculatedGeometry.toString()+"</body></html>");

JOptionPane.showMessageDialog(null, jbl , "Calculated Geometry Information", JOptionPane.PLAIN_MESSAGE);

===================================================================

Am I doing anything wrong in my code??
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Works fine for me.
Try posting the text with lines but use the CODE tags. That might preserve the spaces you are mentioning.
 
Praveen Kumar Jayaram
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for posting repeatedly.
using <code>...</code> did not help me to fix.

Any other alternative??
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well you can try posting the text you want to display. Just replace all spaces with say '$'
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Praveen Kumar Jayaram:
Sorry for posting repeatedly.
using <code>...</code> did not help me to fix.

Any other alternative??



By posting, I meant post it here at the forum.
 
Praveen Kumar Jayaram
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the message to be displayed:
==========================================================
Impeller inlet annulus area$$$$$$$$$=$$$$2728.87 sq mm
Impeller exit annulus area$$$$$$$$$$=$$$$2987.36 sq mm
Impeller effective exit throat area$=$$$$1466.50 sq mm
rms diameter at impeller exit$$$$$$$=$$$$50.505 mm
Exhaust duct exit annulus area$$$$$$=$$$$4047.79 sq mm
rms diameter at exhaust duct exit$$$=$$$$50.763 mm
==========================================================

I have replaced white space by '$' symbol.

I want to retain those spaces in the message when I print it using JOptionpane.showMessageDialog()
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Praveen Kumar Jayaram:
This is the message to be displayed:
==========================================================
Impeller inlet annulus area$$$$$$$$$=$$$$2728.87 sq mm
Impeller exit annulus area$$$$$$$$$$=$$$$2987.36 sq mm
Impeller effective exit throat area$=$$$$1466.50 sq mm
rms diameter at impeller exit$$$$$$$=$$$$50.505 mm
Exhaust duct exit annulus area$$$$$$=$$$$4047.79 sq mm
rms diameter at exhaust duct exit$$$=$$$$50.763 mm
==========================================================

I have replaced white space by '$' symbol.

I want to retain those spaces in the message when I print it using JOptionpane.showMessageDialog()



The 'symbol' for 'space' in HTML is ' ' (with the semi colon)
Just replace '$' with ' ' to get it working.

EDIT> (& n b s p
It got converted to a white space DOH! Just remove the spaces between & n b s p ; and use it. The ';' is required

EDIT AGAIN: Admins help.Is there anyway I can switch off HTML>?

[ August 27, 2008: Message edited by: Maneesh Godbole ]
[ August 27, 2008: Message edited by: Maneesh Godbole ]
 
Praveen Kumar Jayaram
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No just for showing the exact message with spaces, replaced those spaces by $ symbol.

I did not understand what to suggested me in your previous post.
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Praveen Kumar Jayaram:
No just for showing the exact message with spaces, replaced those spaces by $ symbol.

I did not understand what to suggested me in your previous post.



Try this out
 
Praveen Kumar Jayaram
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot
 
reply
    Bookmark Topic Watch Topic
  • New Topic