如何在java中dispose()当前的JIntenalFrame

时间:2017-06-11 09:56:12

标签: java swing windowlistener

  

如何dispose()当前JIntenalFrame

public class A extends JIntenalFrame
{
 class B extends JIntenalFrame
  {
   //i like to dispose current B class to dispose()
   B.dispose();
   }
}

我正在与一些内心JIntenalFrame合作。 有没有办法处理它?<​​/ p>

2 个答案:

答案 0 :(得分:0)

您可以使用JDesktopPane.getSelectedFrame()。dispose();

答案 1 :(得分:0)

  

所有内部类都在自己的路径上工作,所以a遵循我们可以使用它的路径

 public class Main extends JIntenalFrame
{
 public class A extends JIntenalFrame
  {
   //its an inner class
  }
 public class B extends JIntenalFrame
  {
   /*now while disposing the class B extended by the JIntenalFrame
then use the class name and the operation()
*/
 B.this.dispose();//here the actual working code
  }
}

如果您在this.dispose()内使用,则会关闭Main JIntenalFrame,因此在JIntenalFrame内进行操作时,我们可以使用CLASS_NAME.this.operation()。 像明智的

B.this.dispose();