Java 对话服务器芯片
我对JOptionPane.showInputDialog(…)方法(以及JJOptionPane的其他方法)有一种奇怪的行为。 创造的对话似乎永远不会消失。当我在对话框消失后调用Window.getWindows()时,窗口的数量增加了 测试这个程序,你就会明白我的意思:Java 对话服务器芯片,java,swing,jframe,jdialog,Java,Swing,Jframe,Jdialog,我对JOptionPane.showInputDialog(…)方法(以及JJOptionPane的其他方法)有一种奇怪的行为。 创造的对话似乎永远不会消失。当我在对话框消失后调用Window.getWindows()时,窗口的数量增加了 测试这个程序,你就会明白我的意思: public static void main(String[] args) { final JFrame frame = new JFrame(); final JPanel panel =
public static void main(String[] args) {
final JFrame frame = new JFrame();
final JPanel panel = new JPanel();
final JButton button = new JButton("Show Dialog");
panel.add(button);
frame.add(panel);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
JOptionPane.showInputDialog(frame, "Enter some text : ");
System.out.println(Window.getWindows().length);
}
});
frame.setSize(400, 400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
有人能解释发生了什么事吗
有人知道会发生什么吗
Window.getWindows()
始终返回在当前JVM
中创建的每个容器(不带容器返回!isDisplayable
),这些容器从未从JVM内存中消失,也从未被GC'ed
,因为它们是作为资源从本机操作系统中来的
有人知道会发生什么吗
Window.getWindows()
始终返回在当前JVM
中创建的每个容器(不带容器返回!isDisplayable
),这些容器从未从JVM内存中消失,也从未被GC'ed
,因为它们是作为资源从本机操作系统中来的,为什么
你会在答案中反勾选东西
,那实际上不是编码?我们有粗体和斜体。为什么你在回答中反勾东西
那实际上不是编码?我们有加粗的和斜体的。