gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
update this method to be able to enter the search and replace string: public static…
- User
update this method to be able to enter the search and replace string: public static String folderSelectorBox(String search, String replace) {
JFrame frame = new JFrame("Select Folder"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton button = new JButton("Select Folder"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int option = fileChooser.showOpenDialog(frame); if (option == JFileChooser.APPROVE_OPTION) { File selectedFolder = fileChooser.getSelectedFile(); System.out.println("Selected Folder: " + selectedFolder.getAbsolutePath()); returnDirPath = selectedFolder.getAbsolutePath(); // Perform operations on the selected folder here } } }); frame.getContentPane().add(button); frame.pack(); frame.setVisible(true); return returnDirPath; } - Assistant
public static String folderSelectorBox(String search, String replace) {
JFrame frame = new JFrame("Select Folder"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton button = new JButton("Select Folder"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int option = fileChooser.showOpenDialog(frame); if (option == JFileChooser.APPROVE_OPTION) { File selectedFolder = fileChooser.getSelectedFile(); System.out.println("Selected Folder: " + selectedFolder.getAbsolutePath()); String folderPath = selectedFolder.getAbsolutePath(); // Perform search and replace operations on the selected folder here String replacedFolderPath = folderPath.replace(search, replace); System.out.println("Replaced Folder Path: " + replacedFolderPath); returnDirPath = replacedFolderPath; } } }); frame.getContentPane().add(button); frame.pack(); frame.setVisible(true); return returnDirPath;