Something is wrong with JDialog

I am currently trying to print a message to a user in the program I am creating, but the result is not what I expected. As an example, I used the Oracles sugestion application for the message dialog:

    JOptionPane.showMessageDialog(frame, "Eggs are not supposed to be green.");

I get this (note the missing dot at the end and the missing K button in the button):

Ouput of the Program

Is it possible that this is something wrong with my JDK or JRE? In addition, I do not know if this may be important or not, but I program it on the eclipse platform, working on Windows 7.

Change number 1: As he said, I tried a simpler example and got the same result. Here is the code for a simpler example:

public class SampleGUI {

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                JOptionPane.showMessageDialog(
                    null, "Eggs are not supposed to be green.");
            }
        });
    }
}

2: , , , , . , , - . ?

Update on edit2: , . , , , .

3: 7 ubuntu 14.04, ubuntu.

+4
1

, , , , :

http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html

JOptionPane.showMessageDialog invokeLater , ; MouseEvent/ActionEvent, . , invokeLater .

, , , , : EventDispatchThread . EDT, , a paint, layout EDT.

:

public class SampleGUI {

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                JOptionPane optionPane = new JOptionPane("Eggs are not supposed to be green.");
                JDialog generatedDialog = optionPane.createDialog("Message");
                generatedDialog.setVisible(true);
            }
        });
    }
}

http://developer.classpath.org/doc/javax/swing/JOptionPane-source.html ( 926, 368)

, JDialog, repaint, invalidate pack, , .

+1
source

Source: https://habr.com/ru/post/1537028/


All Articles