How to add file browser to Java application?

I am new to Java programming and am creating an application that will add, display and delete files from a given folder location.

I added files using JFileChooser and know how to delete files. However, I am stuck with part of the display.

I want to display files and a folder using a different icon inside my application. I tried to add JFileChooser inside the display panel and disable the menu items and buttons of the dialog box, but I failed. Is there a better way to do this?

+3
source share
3 answers

I prefer the following path.

JFileChooser chooser= new JFileChooser();

int choice = choose.showOpenDialog();

if (choice != JFileChooser.APPROVE_OPTION) return;

File chosenFile = chooser.getSelectedFile();

// You can then do whatever you want with the file.

JFileChooser .

JButton ActionListener.

fileChooseButton.addActionListener( new ActionListener(){
    public void actionPerformed(ActionEvent e){

        // File chooser code goes here usually
    }
});
+10

JFileChooser, java.awt.FileDialog. OS X . FileDialog , JFileChooser - , .

+4

. /, , . FileSystemView. getSystemIcon () . JList/JTable .

+1

Source: https://habr.com/ru/post/1707238/


All Articles