jfilechooser

Refreshing chart when a new file is opened

こ雲淡風輕ζ 提交于 2019-12-24 14:13:45
问题 I have to represent data returned from a file chooser to a chart. Everything works fine until I press the button again and choose a different file. The problem is that instead of representing the new dataset, it's adding it to the previous one. I tried the revalidate , repaint and remove methods, but nothing worked (or I didn't know where to put those methods. My code looks like this: JButton theButton = new JButton("Choose the file"); theButton.addActionListener(new ActionListener() { public

JFileChooser.showOpenDialog not opening, and no error being thrown?

穿精又带淫゛_ 提交于 2019-12-24 09:19:34
问题 Okay, so I'm trying to make a hex editor, and I'm trying to make a load JMenuItem, but it's not working. The JFileChooser OpenDialog just doesn't show up, and no errors are being shown. import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import java.util.Vector; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; public class HexEditor extends JFrame{ JTextArea textArea; JFileChooser chooser;// = new

Java: JFileChooser getting international filenames

痴心易碎 提交于 2019-12-24 00:40:00
问题 I am using JFileChooser and getting file names with Chinese characters in them. JFileChooser displays them properly, and I want to be able to capture these file names and display them back to the user. I have filename: 03 玩愛之徒.mp3 But I end up displaying: 03 ????.mp3 In my code I get... File f1 = fileChooser.getSelectedFile(); log("f1="+ f1.getName()); // gets me 03 ????.mp3 byte[] fname1 = f1.getName().getBytes(); // gets me [B@3f72c47b byte[] fname2 = f1.getName().getBytes("UTF-16"); //

JFileChooser showing outside Full screened JFrame

余生颓废 提交于 2019-12-23 17:25:42
问题 import java.awt.DisplayMode; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JPanel; public class Sample { public static String audioName; /** * @param args the command line arguments */ public static void main(String[] args) { final JFrame frame = new JFrame(); frame.setTitle("Frame"); frame

How can I make a JFileChooser on the Mac that lets users create directories?

爱⌒轻易说出口 提交于 2019-12-23 14:21:24
问题 I have an installer program that lets the user choose a directory in which to install. The JFileChooser implementation on MacOS uses a native dialog (or at least it looks native). That's great. The only problem is there's no way to create a directory from this dialog ... you can only choose a pre-existing one, which is clunky. Is there a way to get this functionality? I use the JFileChooser in "select directories only" mode. Thus it isn't the same dialog as the usual MacOS file picker which

How to stop JFileChooser from being closed when approve or cancel button is pressed?

∥☆過路亽.° 提交于 2019-12-23 12:00:06
问题 I use method showOpenDialog of JFileChooser to open file. How to attach ActionListener to Approve button of JFileChooser and how to stop this dialog from closing after Approve button is clicked and listener completed. For now I have : public class MainFileChooser extends JFileChooser { private FileFilter plainFilter; public MainFileChooser() { super.setMultiSelectionEnabled(true); super.setAcceptAllFileFilterUsed(false); plainFilter = new PlainFilter(); } public int showOpenFileDialog() {

Adding multiple files with JFileChooser

十年热恋 提交于 2019-12-23 07:20:21
问题 I'm looking to make an application that allows you to attach files from your computer. For example, when the JFileChooser opens you have the option to select multiple files and when you click "add" it adds it to the window and you can then have different for what you want to do with those files. Similar to attaching files in an email. All the code I have to show is the JFileChooser because I figure I should learn how to do this before I go any further. Thanks in advance import javax.swing

JFileChooser vs JDialog vs FileDialog

我与影子孤独终老i 提交于 2019-12-22 10:59:50
问题 I need to know which of the 3 is best for me. My requirements are as follows in order of importance: Save and load files with ease. File type filter during file selection (not afterwards). Look and feel is exactly the same as the native OS L&F. If there is a dialog that I've not mentioned that would be more ideal, please let me know. 回答1: What is the rest of your application written in? If you used AWT you should use FileDialog. If you used Swing you should use JFileChooser. Both classes meet

How to get open file popup

浪子不回头ぞ 提交于 2019-12-22 09:02:26
问题 Right now, I have a set class path, but I want to have an open file pop up and the user chooses which file to open. I've tried JFileChooser, but haven't been successful so far. Here's my code: public static void main(String[] args) throws IOException { JFileChooser chooser = new JFileChooser(); int returnValue = chooser.showOpenDialog( null ) ; if( returnValue == JFileChooser.APPROVE_OPTION ) { File file = chooser.getSelectedFile() ; } // I don't want this to be hard-coded: String filePath =

Panel losing color

孤人 提交于 2019-12-20 07:44:55
问题 When I click on the button that activates the file chooser, and add the resulting file the panel color disappears. Does anyone know why this is happening? import javax.swing.JPanel; import javax.swing.JButton; import javax.swing.JLabel; import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.io.IOException; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing