jfilechooser

How to open files in Java Swing without JFileChooser

落花浮王杯 提交于 2019-12-09 03:20:33
问题 I'm using Java Swing (GUI) and I want to add a button to my project for opening files. I don't like the JFileChooser since it opens a small window for browsing through the files of the directories. Can I use something else instead of the JFileChooser under Java Swing ? I've tried to use elements of SWT but it didn't work, meaning is the use of the button object and then use it inside the JFrame , but that failed, so I guess SWT and Swing don't mix together? Here is the example of Java Swing

Java JFileChooser with Filter to supposedly display ONLY directories fail to show just directories

徘徊边缘 提交于 2019-12-08 19:23:35
问题 (Thanks in advance! Please let me know if you need more info. Sample code at the bottom.) Problem I'm trying to solve: I'm trying to get this JFileChooser object to display only directories (and not files), through the use of a javax.swing.filechooser.FileFilter object that has this in the accept(File file) overridden method: return file.isDirectory(); . However, at least on my mac, it doesn't seem to prevent files from being displayed along with the directories (it does prevent files from

JFileChooser: Cannot select Desktop when Selection Mode is File and Directories

邮差的信 提交于 2019-12-08 12:33:18
问题 I ran into an issue with JFileChooser and wanted to see if there is a workaround. If the JFileChooser is created and the setFileSelectionMode is FILES_AND_DIRECTORIES, when a user clicks a shortcut button on the left (in XP) such as Desktop or My Documents or drop down to Desktop, the field is not placed in the File Name JTextPane. And when clicking the "Select/Accept" button, nothing happens (because isDirectorySelected() returns false for some reason). Overriding the approveSeletion does

JFile chooser window?? How do I filter files?

我的梦境 提交于 2019-12-08 09:39:36
问题 In NetBeans, there is an object called a JFileChooser. I wanted to ask how you can set up a filter in order to just show files that have a .wds extension. .wds is an extension I use in my program. 回答1: You have to create a filter class for the *.wds files: class MyFilter extends javax.swing.filechooser.FileFilter { public boolean accept(File file) { String filename = file.getName(); return filename.endsWith(".wds"); } public String getDescription() { return "*.wds"; } } then you add the

Java how to user JFileChooser to save a excel file created by Apache POI

空扰寡人 提交于 2019-12-08 06:13:19
问题 I want to save a spreadsheet file to a user custom file folder, people suggest to use JFileChooser , but I actually don't know how to achieve it. I have my current example code here: import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook;

Java KeyBindings with JFileChooser

坚强是说给别人听的谎言 提交于 2019-12-07 18:53:50
问题 I would like to add Key bindings to my JFileChooser in order to open a file preview window when the SPACE key is pressed. Because of the source code is too big, I just did a simple dirty code : MainWindow.java package test; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class MainWindow extends JFrame { public MainWindow() { this.setTitle("Test Window"); Dimension dim = new Dimension(800, 600); this.setSize(dim); this.setPreferredSize(dim); MainPanel pane = new

Is there a bug setting title using JFileChooser.showDialog(Component, String) in Mac OS X?

落花浮王杯 提交于 2019-12-07 09:02:45
问题 Search doesn't turn anything up for this problem. I'm using simple code to display a JFileChooser dialog with customized title and accept button: JFileChooser fc = new JFileChooser(); fc.showDialog(null,"MyText"); On Windows 7 this works as expected: a Save Dialog is displayed, with "Save" replaced by "MyText" on the Accept button and dialog title. However, on Mac OS X, only the Accept button text is changed - the dialog title is blank. I'm using Java SE 7 and MacOS 10.8.5. By inserting this

Start a JFileChooser with files ordered by date

☆樱花仙子☆ 提交于 2019-12-07 07:58:52
问题 A recent question asked: How can I start the JFileChooser in the Details view? and the answer provided a nice technique for doing that. I'd like to raise the aspiration here one level: given that I now know how to open the JFileChooser in details view, can I also get it to open with the files ordered by date? I know the user can of course click on the headings, but is there a way to make this happen in the code? 回答1: I don't know of any API to do this. The following code finds the table used

Is there a way to improve JFileChooser look and feel under Ubuntu?

被刻印的时光 ゝ 提交于 2019-12-07 07:30:50
问题 I've been making a program that uses a JFileChooser. I've set the application up with UIManager.getSystemLookAndFeelClassName() Which works just fine for pretty much everything under Ubuntu. The only problem I've run into so far is that the JFileChooser comes out looking pretty awful: Is there a way to make this look like the default file chooser in Ubuntu? ie. I've tried using UIManager.getCrossPlatformLookAndFeelClassName() Which makes the JFileChooser dialog look better , but still not

improving JFileChooser under Ubuntu 12.04 (GTK)

自古美人都是妖i 提交于 2019-12-07 06:02:55
问题 I have a problem with the JFileChooser under Ubuntu 12.04. I use this code to set the look and feel: javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName()); And it looks like this. It's very uncomfortable to use and it looks very ugly: http://www9.picfront.org/token/9sRH/2012/05/15/2062476.jpg I would like it to look like this: http://www4.picfront.org/token/1lpa/2012/05/15/2062477.jpg Using the hint from this post, I tried to use FileDialog instead of the