gpt4 book ai didi

java - 我怎样才能在 JAVA swing 的文件中使用类似 html 文件按钮的浏览器?

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:52:28 24 4
gpt4 key购买 nike

我正在尝试通过 Swing 创建我的第一个 UI 页面。在此页面中,我希望浏览一个文件。有人可以帮我实现这个目标吗?

最佳答案

查看来自 Sun 的教程页面:http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html .

基本实现包括:

//Create a file chooser
final JFileChooser fc = new JFileChooser();
...
//In response to a button click:
int returnVal = fc.showOpenDialog(aComponent);

返回值为您提供有关用户是单击“确定”还是“取消”等的信息,然后您可以查询文件选择器对象以找出选择了哪个文件。

关于java - 我怎样才能在 JAVA swing 的文件中使用类似 html 文件按钮的浏览器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/465107/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com