日食中的JOptionPane非常小

问题描述 投票:0回答:1

我正在使用Eclipse Photon 2018并使用Java制作一个简单的项目。我开始使用JOptionPane,由于某种原因 - 尺寸很小,如下图所示:

enter image description here

我的代码:

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);
    }

}

consul E UI.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();
    }

}

graphical UI.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);
}
java eclipse swing joptionpane
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.