1
我正在构建一个java程序,其中您应该能够选择一个文件。对话框应该弹出为JInternalFrame,并且不应该是自己的窗口。我的进步:JFileChooser as JInternalFrame
JFileChooser chooser = new JFileChooser();
JInternalFrame fr = new JInternalFrame("Öffnen", true, // resizable
false, // closable
true, // maximizable
true);// iconifiable);
fr.add(chooser);
fr.setSize(300, 600);
fr.setVisible(true);
JOS.mainWindow.jdpDesktop.add(fr);
chooser.setVisible(true);
chooser.setSize(300, 600);
chooser.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
fr.setVisible(false);
JOS.mainWindow.jdpDesktop.remove(fr);
}
});
它关闭,如果我按下关闭按钮,但我没有得到一个事件如果在用户按下“打开”。有没有我可以使用的ActionListener?还有其他方法可以做到吗? 谢谢! -Jakob
'JFileChooser'是一个组件,它有一个方便的方法,它允许你显示一个对话框。你可以使用像'JOptionPane.showInternalOptionDialog'这样的东西,并通过它呈现'JFileChooser'的一个实例 – MadProgrammer