Page 1 of 2 12 LastLast
Results 1 to 20 of 39
Like Tree1Likes

Thread: Dialog box in programs using JOptionPane and Jrame is not showing what's in my code

  1. #1
    shiri4frnz is offline Member
    Join Date
    Sep 2012
    Posts
    14
    Rep Power
    0

    Default Dialog box in programs using JOptionPane and Jrame is not showing what's in my code

    Dialog box in programs using JOptionPane and Jrame is not showing what's in my code-prob1.jpg

    The dialog box is showing evrything one character ahead according to ASCII...having the same problem while running the program through dos..help me out someone..

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,576
    Rep Power
    23

    Default Re: Dialog box in programs using JOptionPane and Jrame is not showing what's in my co

    You forgot to post the code that shows the problem.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    PhQ's Avatar
    PhQ
    PhQ is offline Senior Member
    Join Date
    Mar 2010
    Location
    Lithuania
    Posts
    358
    Rep Power
    5

    Default Re: Dialog box in programs using JOptionPane and Jrame is not showing what's in my co

    Quote Originally Posted by Norm View Post
    You forgot to post the code that shows the problem.
    I think his code is on the screenshot that he provided.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,576
    Rep Power
    23

    Default Re: Dialog box in programs using JOptionPane and Jrame is not showing what's in my co

    Very hard to copy and paste code for testing from an image.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    PhQ's Avatar
    PhQ
    PhQ is offline Senior Member
    Join Date
    Mar 2010
    Location
    Lithuania
    Posts
    358
    Rep Power
    5

    Default Re: Dialog box in programs using JOptionPane and Jrame is not showing what's in my co

    Quote Originally Posted by Norm View Post
    Very hard to copy and paste code for testing from an image.
    I just typed it all in my IDE and it was working fine.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Dialog box in programs using JOptionPane and Jrame is not showing what's in my co

    I have a theory, but I need one more bit of information from you. Add this line at the top of the main(...) method:
    Java Code:
    JDialog.setDefaultLookAndFeelDecorated(true);
    Does the title of the dialog still read "Input"?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Dialog box in programs using JOptionPane and Jrame is not showing what's in my co

    Does this look familar?
    Dialog box in programs using JOptionPane and Jrame is not showing what's in my code-dbodfm.jpg

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  8. #8
    shiri4frnz is offline Member
    Join Date
    Sep 2012
    Posts
    14
    Rep Power
    0

    Default Re: Dialog box in programs using JOptionPane and Jrame is not showing what's in my co

    If the jpg i uploaded caused inconveniance in replying,here's my CODE

    import javax.swing.JOptionPane;

    class MyFirstGUI {
    public static void main(String[] args) {

    String first = JOptionPane.showInputDialog("Enter the first number");
    String second = JOptionPane.showInputDialog("Enter the second number");

    int n = Integer.parseInt(first);
    int m = Integer.parseInt(second);
    int sum = n + m;

    JOptionPane.showMessageDialog(null, "sum = "+sum, "Sum of 2 numbers", JOptionPane.PLAIN_MESSAGE);

    }

    }

  9. #9
    shiri4frnz is offline Member
    Join Date
    Sep 2012
    Posts
    14
    Rep Power
    0

    Default Re: Dialog box in programs using JOptionPane and Jrame is not showing what's in my co

    Does this look familar?
    I think you are at the verge of telling me how to rectify my problem.

  10. #10
    shiri4frnz is offline Member
    Join Date
    Sep 2012
    Posts
    14
    Rep Power
    0

    Default Re: Dialog box in programs using JOptionPane and Jrame is not showing what's in my co

    I have a theory, but I need one more bit of information from you. Add this line at the top of the main(...) method:
    Java Code:
    1
    JDialog.setDefaultLookAndFeelDecorated(true);
    Does the title of the dialog still read "Input"?
    The title is Joqvu now,which is exatly like the line below i.e. 1 character ahead of what i want

  11. #11
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Dialog box in programs using JOptionPane and Jrame is not showing what's in my co

    Just as I expected. OK, here's my theory.

    You have no problem with Java per se. Somebody has pranked you by installing a font that has glyphs for one character ahead: whether from Java or any other software, that font will always show 'b' when it should be showing 'a'. The prankster has also managed to set this as the default font for Swing.

    Search your computer's Program Files\Java folder for any file(s) named 'swing.properties'. If you find any (there can be more than one) do NOT summarily delete them: post the contents of one here (could be quite long -- make sure to use code tags, not quote tags -- BB Code List - Java Programming Forum).

    The giveaway is that the same crazy font shows up in the other screen image I found -- from a thread on a forum for that software, which is Java-based, that had no solution, nor any suggestion of one. It's identical to the font in your screenshot. The kerning is out of whack -- in both screenshots, the lowercase f and i are not centered between the preceding and following characters but are jammed up to the preceding character, with too much whitespace to the right.

    Note that creating/modifying a swing.properties file isn't the only way this could be done. If you don't have a swing.properties file we can look at other, less obvious, possibilities.

    You could also try doing some detective work: look for the culprit font using charmap.exe or by double clicking each font in turn. If you can find the font, post its name here: both the name as shown in the font viewer or Windows\Fonts folder as well as its filename (right-click -> Properties).

    db
    Fubarable likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  12. #12
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Dialog box in programs using JOptionPane and Jrame is not showing what's in my co

    /taps foot impatiently

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  13. #13
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Dialog box in programs using JOptionPane and Jrame is not showing what's in my co

    New theory: the font came from an alien race who spell 'Input' as 'Joqvu' and who have now abducted our OP to keep their presence here on Earth a secret from the human race. Alternatively, the OP could be an alien testing the waters to see whether us humans would be smart enough to break their primitive font-based cipher.

    Either way, it looks like we won't get to know the name of the errant font, which would have been valuable information, seeing as how considerable googling failed to turn up more than one similar experience, without a resolution. Disappointing, to say the least.

    As this isn't really a Java problem, I'll move this thread to the forum lobby in a day or two.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  14. #14
    shiri4frnz is offline Member
    Join Date
    Sep 2012
    Posts
    14
    Rep Power
    0

    Default Re: Dialog box in programs using JOptionPane and Jrame is not showing what's in my co

    I've tried a lot to find out whether there is something wrong with any of the fonts or not but haven't found out anything abnormal.I have used both charmap and opened every font one by one too,but both didn't show me any abnormal font...what should i do??
    This problem is really getting me frustrated now,don't know what will i do if i don't get out of this mess.I really badly want to get back to my programming.I was really into it..

  15. #15
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: Dialog box in programs using JOptionPane and Jrame is not showing what's in my co

    It's also possible it's loading a font file in the runtime settings for Eclipse (which is what the IDE looks like).
    You could check the Run Configurations.
    Please do not ask for code as refusal often offends.

  16. #16
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Dialog box in programs using JOptionPane and Jrame is not showing what's in my co

    Did you check for a swing.properties file?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  17. #17
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Dialog box in programs using JOptionPane and Jrame is not showing what's in my co

    Quote Originally Posted by Tolls View Post
    It's also possible it's loading a font file in the runtime settings for Eclipse (which is what the IDE looks like).
    You could check the Run Configurations.
    But.
    Quote Originally Posted by shiri4frnz View Post
    ...having the same problem while running the program through dos..
    However it's not clear whether that run was of a .class file or an executable jar built by Eclipse ... I don't use Eclipse and I don't know whether weird settings can carry over to an executable jar.

    A good test would be to transfer both a .class file and an executable jar to another computer and test there. Another metric could be to sysout the LookAndFeel.
    Java Code:
    System.out.println(UIManager.getLookAndFeel().getName());
    With enough relevant information, I still hope we can get to the bottom of this.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  18. #18
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: Dialog box in programs using JOptionPane and Jrame is not showing what's in my co

    Didn't spot that they'd run it in DOS.
    Please do not ask for code as refusal often offends.

  19. #19
    shiri4frnz is offline Member
    Join Date
    Sep 2012
    Posts
    14
    Rep Power
    0

    Default Re: Dialog box in programs using JOptionPane and Jrame is not showing what's in my co

    Quote Originally Posted by DarrylBurke View Post
    Did you check for a swing.properties file?

    db
    I couldn't find one...

  20. #20
    shiri4frnz is offline Member
    Join Date
    Sep 2012
    Posts
    14
    Rep Power
    0

    Default Re: Dialog box in programs using JOptionPane and Jrame is not showing what's in my co

    Quote Originally Posted by DarrylBurke View Post
    But.However it's not clear whether that run was of a .class file or an executable jar built by Eclipse ... I don't use Eclipse and I don't know whether weird settings can carry over to an executable jar.

    db
    I ran it via the .class file.

Page 1 of 2 12 LastLast

Similar Threads

  1. Default Focus in JOptionPane Dialog
    By Gajesh Tripathi in forum AWT / Swing
    Replies: 5
    Last Post: 11-11-2009, 02:59 PM
  2. Not-resizable (J)dialog showing Maximize Menu !!!
    By playwin2 in forum AWT / Swing
    Replies: 7
    Last Post: 09-08-2008, 12:51 AM
  3. JOptionPane dialog (Localizing)
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-14-2008, 11:36 AM
  4. JOptionPane - message dialog
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-17-2007, 09:11 AM
  5. JOptionPane - input dialog
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-17-2007, 09:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •