Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Java 

Extremely easy question. :)

I will preface by saying I'm a complete noob in all programming...which will become apparent when I post my question.

How can I make this into one dialog box that reads like the following link:

https://gyazo.com/96c356f050909fbc477fa3222b17bd1f

My first thought was to use JOptionPane.showMessageDialog(null, ""); beside each row, but that just made multiple dialog boxes.

Code
import javax.swing.JOptionPane;

public class test {

public static void main(String[] args) {

    System.out.println("  J  A  V  V  A ");
    System.out.println("  J    A A  V   V  A A");
    System.out.println("J    J   AA  V V  AA");
    System.out.println(" J  J   A  A  V  A  A");
}
}

I just began on the second chapter of Introduction to Java Programming and this was one of the questions, but I took it a step further by putting it in a dialog box. :P

Would you have to put all of that "JAVA" into one set of quotation marks for it to work or is there another way?

Thanks in advance for helping me learn. :)
" J A V V A \n J A A V V A A\nJ J AA V V AA\n J J A A V A A"

That is what you need to use. \n will create a new-line and as such can be used to put multiple lines of text into a method that supports only a single string. Keep in mind that I don't use Swing so cannot verify that JOptionPane will support multi-line display.
I don't know how to Java.
(Jan 17, 2013 10:03 PM)Psifour Wrote:  " J A V V A \n J A A V V A A\nJ J AA V V AA\n J J A A V A A"

That is what you need to use. \n will create a new-line and as such can be used to put multiple lines of text into a method that supports only a single string. Keep in mind that I don't use Swing so cannot verify that JOptionPane will support multi-line display.

Ah-ha! You are the man, good sir. I didn't realize \n would make it go to the next line. It works, now I would just have to figure out the spacing, which I'm messing around with now. Thanks. :)
JOptionPane actually uses Arial or Times New Roman to display text instead of a console font, so the spacing will be pretty wacky. (No set width characters)
Yeah, I found that out. Lol. I made it look decent, but it didn't line up extremely well.

What's another way of doing it?
I believe you can change the font of the JOptionPane window to a fixed width font

Edit: apparently you can use this code before your messageDialogs to change the font:

Code
javax.swing.UIMAnager.put("OptionPane.font", yourFont);
(Jan 18, 2013 10:54 AM)+TOAST Wrote:  I believe you can change the font of the JOptionPane window to a fixed width font

Edit: apparently you can use this code before your messageDialogs to change the font:

Code
javax.swing.UIMAnager.put("OptionPane.font", yourFont);

Thanks for the info. I will try this out now. :)


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by SIM-2362662Jan 12, 2020 05:30 PM 5 215 Jan 12, 2020 05:30 PM
Last Post: Riԁdle
[.NET] by Rayquaza™Jun 20, 2013 12:15 PM 2 113 Jun 20, 2013 12:15 PM
Last Post: Cody8295
[C] by antigravJan 16, 2013 06:52 PM 4 122 Jan 16, 2013 06:52 PM
Last Post: notsteve