java 在 eclipse 上的错误

errors with java on eclipse

我做错了什么以及如何解决?我在 eclipse 上 运行。

import java.awt.Component;

import javax.swing.Icon;

public class JOptionPane {

    public static void main(String[] args) {

        // JOptionPane inputs
        Component parentComponent = null;
        Object message = "What do you think of Hudson?";
        String title = "VERY IMPORTANT!";
        String choice1 = "1";
        String choice2 = "2";
        String choice3 = "3";
        int optionType = JOptionPane.YES_NO_OPTION;
        int messageType = JOptionPane.ERROR_MESSAGE;
        Icon icon = null;

        // JOption pane display
        Object[] options = { choice1, choice2, choice3 };
        int option = JOptionPane.showOptionDialog(parentComponent, message, title,
                optionType, messageType, icon, options, options[2]);

        // Switch
        switch (option) {
        case 0:
            //Button 1 result
            break;
        case 1:
            //Button 2 result
            break;
        default:
            //Button 3 result
            break;
        }

        return;
    }
}

错误:

您的 class 名称与 javax.swing.JOptionPane 冲突 - 将其重命名为其他名称,以便您可以导入 class

需要赋值时使用

int optionType = javax.swing.JOptionPane.YES_NO_OPTION;