Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Java JOptionPane text unreadable

  1. #1
    Junior Member
    Join Date
    May 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java JOptionPane text unreadable

    When I use this code
    import javax.swing.*;
     
    public class Swag {
     
        public static void main ( String[] args) {
            String name = JOptionPane.showInputDialog("What is your name?");
     
            String input = JOptionPane.showInputDialog("How old are you?");
            int age = Integer.parseInt(input);
     
            System.out.print(" Hello, " +name);
            System.out.println("Next year you'll be " +(age+1));
        }
    }
    And run it, it ends up looking like thisH1765.png I'm running windows 8, the latest x64 JDK, no type of custom font or anything that I know of. I've run this through eclipse, CMD, and uninstalled and reinstalled Java. I tried using another example of JOptionPane usage from a site and running it, still looks the same.


  2. #2
    Member
    Join Date
    Feb 2014
    Posts
    180
    Thanks
    0
    Thanked 48 Times in 45 Posts

    Default Re: Java JOptionPane text unreadable

    I can't reproduce your problem, but I'm on Linux.

    Do you get 2 option panes displayed one after the other when you click OK/Cancel on the first option pane? If so, does the second option pane have the same problem?

    Also, does the same problem occur if you comment out the second option pane (so that your program will display only 1 option pane)?

    Just speculating, try the following to see if it makes a difference:
    public class Swag {
     
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
     
                @Override
                public void run() {
                    String name = JOptionPane.showInputDialog("What is your name?");
     
                    String input = JOptionPane.showInputDialog("How old are you?");
                    int age = Integer.parseInt(input);
     
                    System.out.print(" Hello, " + name);
                    System.out.println("Next year you'll be " + (age + 1));
                }
     
            });
        }
    }

  3. The Following User Says Thank You to jashburn For This Useful Post:

    GregBrannon (May 19th, 2014)

Similar Threads

  1. Java Learning Help: JOptionPane / Listener
    By Nicken99 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 12th, 2014, 04:58 AM
  2. Replies: 3
    Last Post: March 4th, 2013, 10:51 AM
  3. Replies: 0
    Last Post: October 29th, 2011, 02:37 AM
  4. Replies: 1
    Last Post: July 16th, 2011, 08:55 AM
  5. java program to copy a text file to onother text file
    By francoc in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: April 23rd, 2010, 03:10 PM

Tags for this Thread