Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何修复:“;无法解析方法。setVisible();?_Java_Jframe - Fatal编程技术网

Java 如何修复:“;无法解析方法。setVisible();?

Java 如何修复:“;无法解析方法。setVisible();?,java,jframe,Java,Jframe,当某个动作发生时(他们单击按钮),我试图打开JFrame,但是,setVisible()方法对我不起作用。我使用了其他方法来打开它,但它们不起作用 extraButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { otherOptions other = new otherOptions();

当某个动作发生时(他们单击按钮),我试图打开JFrame,但是,
setVisible()
方法对我不起作用。我使用了其他方法来打开它,但它们不起作用

extraButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            otherOptions other = new otherOptions();
            other.setVisible(true); // Shows error "cannot resolve method"
        }
    });
试图打开另一个JFrame


您可能希望使用setOnClickListener方法,而不是addActionListener

extraButton.setOnClickListener(new View.OnClickListener() {

   @Override
   public void onClick(View view) {

   }
});

尝试
otherOption.show()。有一段时间,
setVisible
尚未引入。我想您有一个旧的编译器或运行时。

您确定
otherOptions
class正在从
JFrame
class导入属性吗?像
public类otherOptions扩展JFrame
?您的
otherOptions
类是否声明
setVisible
?它是否扩展了实现
setVisible
的其他类?(这是一个基本的Java东西。实例方法必须在类或类的超类中声明,否则编译器将无法解析它。)我不这么认为,我只是在
otherOptions
中添加了另一张图片。如果我要扩展它或创建一个实例方法,我会在哪里做,如何做?