Results 1 to 10 of 10
- 03-02-2012, 05:14 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 18
- Rep Power
- 0
JOptionPane display on seperate lines
Hi everyone,
I am trying to display an output message using JOptionPane. I want to display the message on a number of lines. I have tried numerous ways and can't seem to find a solution. If anyone could give me a simple example or provide a link to where I could find a solution, it would be greatly appreciated.
Here's an example of what i'm trying to do;
import javax.swing.JOptionPane;
public class NewLine
{
public static void main(String[] args)
{
JOptionPane.showMessgeDialog(null, "hello")/n
("my name is: ")/n
("xxxx");
System.exit(0);
}
}
Thanks in advance.
- 03-02-2012, 05:18 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
Re: JOptionPane display on seperate lines
According to the API documentation, if the message parameter is a Component it will be displayed as is; a JTextArea (for example) is such a Component.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-02-2012, 05:22 PM #3
Member
- Join Date
- Nov 2011
- Posts
- 18
- Rep Power
- 0
Re: JOptionPane display on seperate lines
I'm sorry, i'm very new to this. What does that mean?
- 03-02-2012, 06:13 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
- 03-02-2012, 07:52 PM #5
Member
- Join Date
- Nov 2011
- Posts
- 18
- Rep Power
- 0
Re: JOptionPane display on seperate lines
I have now but i still don'y understand what you are saying
- 03-02-2012, 08:19 PM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
Re: JOptionPane display on seperate lines
Ok, we'll do it the other way around: does that 'message' parameter have to be a String?
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-02-2012, 08:59 PM #7
Member
- Join Date
- Nov 2011
- Posts
- 18
- Rep Power
- 0
Re: JOptionPane display on seperate lines
The example i provided in my first message was only a tiny piece of my program. The input from the JOptionPane input window is a String but is then converted to an int.
Kind Regards,
David
- 03-02-2012, 09:15 PM #8
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
Re: JOptionPane display on seperate lines
That's not what I asked; I'll rephrase my question: according to the API documentation that 'message' parameter can be an array of objects or a Component (or a simply String). Can you supply an array of Strings? Or a Component that displays multiple lines of text? Read the first part of that API documentation again and don't go hunting for a method that does it all for you.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-02-2012, 09:31 PM #9
Member
- Join Date
- Nov 2011
- Posts
- 18
- Rep Power
- 0
Re: JOptionPane display on seperate lines
I'm not going to get what i'm looking for here. I am a complete beginner. Thanks for you time.
- 03-02-2012, 09:56 PM #10
Similar Threads
-
JOptionPane - Message dialog box does not display
By aibao in forum NetBeansReplies: 4Last Post: 05-15-2011, 04:47 AM -
How do i display a list of strings on one JOptionPane.showMessageDialog?
By Izuba in forum New To JavaReplies: 21Last Post: 10-15-2010, 09:20 AM -
No meesage display for JOptionPane.showMessageDialog in VnC or Solaris
By quest4qwerty in forum AWT / SwingReplies: 1Last Post: 10-29-2008, 07:50 AM -
[SOLVED] Writing ArrayList to Text File on seperate Lines
By shinjitsunohana in forum New To JavaReplies: 9Last Post: 08-27-2008, 05:53 PM -
JOptionPane Display Difficulties
By kewlgeye in forum New To JavaReplies: 7Last Post: 05-09-2008, 08:09 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks