所以我已经创建了一个Java应用程序,我有一个主表单,我通过单击jbutton运行这个类PathBrowser,但是JFileChooser运行了两次,我尝试从我的主表单中添加开对话框,这样我就可以在窗口上有相同的徽标了。
这是我的密码:
public class PathBrowser {
public static String filepath = null;
public static void main(String[] args)
{
JButton select = new JButton();
JFileChooser browse = new JFileCh
我在我的程序中放了一个JFileChooser,但它只接受图像。所以我决定添加过滤器:
代码
import javax.swing.*;
public class fileChooser {
public static void main(String[] args) {
JPanel panel = new JPanel();
final JFileChooser fc = new JFileChooser();
int file = fc.showOpenDialog(panel);
fc.addChoosableFileFilter(new
当我从我的项目scr目录给出图像的绝对路径时,它会加载图像,但是当我试图从指定的路径或相对路径加载图像时,它会显示为空错误,它不会读取图像。
具体而言,我有使用JFilechooser目录的get路径,它只显示.jpg映像,并将文件列表提供给文件类型,然后逐个将图像存储在字符串变量中,然后使用该变量加载图像。
我的代码:
final String fpath;
final File dir = new File("");
final JFileChooser file;
file = new JFileChooser();
file.setCurrentDirectory(di
我想问一下,如何从数据库下载一个文件并使用Jfilechooser保存它。你能告诉我这是怎么回事吗?
koneksi_db();
JFileChooser fs = new JFileChooser();
fs.setDialogTitle("save a file");
int result = fs.showSaveDialog(null);
try {
PreparedStatement ps = conn.prepareStatement("select * from file where nama = ?");
ResultSet r
我正在尝试从JFileChooser获取文件的大小,这样我就可以在表格中打印它,我该怎么做?
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
String[] fileNames = fileChooser.getSelectedFile().list();
int fileSize;
for (int i = 0; i < files.length; i++) {
int fileSize = fi