0

I am using Eclipse Photon 2018 and making a simple project using Java. I started to use JOptionPane and for some reason - the size is tiny, as you can see in the image below:

enter image description here

My code:

Main.java:

public class Main {

    public static void main(String[] args) {
        Messageable ui = new GrapghicalUI();
        String res = ui.getString("what is your name? ");
        ui.showMessage("hi" +res);
    }

}

ConsuleUI.java:

import java.util.Scanner;

public class ConsoleUI implements Messageable{
    private Scanner s = new Scanner(System.in);

    @Override
    public void showMessage(String str) {
        System.out.println(str);
    }

    @Override
    public String getString(String msg) {
        System.out.println(msg);
        return s.next();
    }

}

GraphicalUI.java:

import javax.swing.JOptionPane;

public class GrapghicalUI implements Messageable {

    @Override
    public void showMessage(String str) {
        JOptionPane.showMessageDialog(null, str);
    }

    @Override
    public String getString(String msg) {
        return JOptionPane.showInputDialog(msg);
    }

}

Messageable:

public interface Messageable {
    void showMessage(String str);
    String getString(String msg);
}
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Eliko
  • 361
  • 1
  • 3
  • 5
  • See https://stackoverflow.com/questions/26913923/how-do-you-change-the-size-and-font-of-a-joptionpane – Ori Marko Nov 08 '18 at 14:54
  • 1
    Why do you have 4 classes to display a simple JOptionPane? When problem solving learn to simplify the problem. That way you know if the problem is related to your overall design or something else. So try just displaying the JOptionPane from the main() method to see if you have the same problem. Also, all Swing components should be created and modified on the `Event Dispatch Thread (EDT)`. So you need to use SwingUtilities.invokeLater(). Read the section from the Swing tutorial on [Concurrency](https://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html) for more information. – camickr Nov 08 '18 at 16:05

1 Answers1

1

It's quite possibly a problem with Windows application scaling on a high DPI monitor. Usually it can be fixed by enabling "Override High DPI scaling behavior" under the compatibility tab of the properties of an executable file.

This question was posted on Microsoft support and can be found here

Since the dialog you see is from a separate program from the IDE itself, the scaling won't match as it has nothing to do with it. However, setting the above mentioned option will most likely not be very helpful as the executable gets replaced each time you build/compile it.

Azuf
  • 11
  • 1