如何在Java Swing中打开给定文件的属性窗口?

huangapple go评论70阅读模式
英文:

How to open up a given file's properties window in Java Swing?

问题

我想展示一个文件的属性窗口。我所说的属性窗口是:

属性窗口:

如何在Java Swing中打开给定文件的属性窗口?

我想要能够使用Java来打开那个窗口或一个通用的Java Swing窗口,以显示并能够编辑文件的属性,就像图像中的属性窗口可以一样。

英文:

Lets say I have the path to a file and I want to show a files property window. What I mean by property window is:

Properties window:

如何在Java Swing中打开给定文件的属性窗口?

I want to be able to open that window or a universal Java Swing window using java to show and be able to edit the file's attributes like the properties window in the image can?

答案1

得分: 1

很难在Java中打开属性窗口(内置于操作系统中的) ,因为属性窗口会因操作系统而异,且不会对所有操作系统都友好。Java中有许多方法,可以在使用Swing制作类似窗口时为您提供很好的起点。首先,以下是一些可能有帮助的方法:

File.getAbsolutePath -> 返回文件的绝对路径

Files.getAttribute -> 返回包含文件创建时间的FileTime对象。

File.lastModified -> 返回文件的最后修改日期。

我强烈建议您在提问之前先进行一些研究。

英文:

It's hard to open the Properties Window (built into the Operating System) in Java, because the Properties Window will vary per OS, and will not make it friendly for all Operating Systems. Java is loaded with many methods that already can give you a head start on making one similar using Swing. As a start, here are some methods that may be helpful:

File.getAbsolutePath -> Returns the Absolute Path of the File

Files.getAttribute -> Returns a FileTime Object which contains the creation time of the File.

File.lastModified -> Returns last modified date of File.

I strongly suggest you should do some research first before asking.

huangapple
  • 本文由 发表于 2020年9月2日 04:26:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/63694991.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定