To create an Arabic JFileChooser (RTL), I use the following:
MyFileChooser:
import javax.swing.JOptionPane; import javax.swing.UIManager; import javax.swing.JFileChooser; import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.filechooser.FileView; import java.io.File; import java.awt.ComponentOrientation; import java.awt.Dimension; public class MyFileChooser extends JFileChooser { private String extension; private String title; public MyFileChooser(String extension, String title) { super(); this.extension = extension; this.title = title; addChoosableFileFilter(new FileNameExtensionFilter(String.format("(*.%1$s) ููุท %1$s ู
ููุงุช", extension), extension)); applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
Main:
import java.awt.*; import javax.swing.*; import javax.swing.border.*; import java.awt.event.*; public class MainFrame extends JFrame implements ActionListener { public MyFileChooser chooser; public MainFrame() { super("Main Frame"); setDefaultCloseOperation(EXIT_ON_CLOSE); try{ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());} catch(Exception e){ System.out.println("Unable to load Windows look and feel");} setPreferredSize(new Dimension(300, 100)); ((JPanel) getContentPane()).setBorder(new EmptyBorder(13, 13, 13, 13) ); setLayout(new FlowLayout()); JButton btn = new JButton("Open"); btn.setActionCommand("myButton"); btn.addActionListener(this); add(btn); JPanel panel = new JPanel(); UIManager.put("FileChooser.saveButtonText", "ุญูุธ"); UIManager.put("FileChooser.openButtonText", "ูุชุญ"); UIManager.put("FileChooser.cancelButtonText", "ุฅูุบุงุก"); UIManager.put("FileChooser.updateButtonText", "ุชุญุฏูุซ"); UIManager.put("FileChooser.helpButtonText", "ู
ุณุงุนุฏุฉ"); UIManager.put("FileChooser.saveButtonToolTipText", "ุญูุธ ู
ูู"); UIManager.put("FileChooser.openButtonToolTipText", "ูุชุญ ู
ูู"); UIManager.put("FileChooser.cancelButtonToolTipText", "ุฅูุบุงุก"); UIManager.put("FileChooser.updateButtonToolTipText", "ุชุญุฏูุซ"); UIManager.put("FileChooser.helpButtonToolTipText", "ู
ุณุงุนุฏุฉ"); UIManager.put("FileChooser.listViewButtonToolTipText", "ูุงุฆู
ุฉ"); UIManager.put("FileChooser.lookInLabelText", "ุจุญุซ ูู:"); UIManager.put("FileChooser.newFolderToolTipText", "ุฅูุดุงุก ู
ุฌูุฏ ุฌุฏูุฏ"); UIManager.put("FileChooser.fileNameLabelText", "ุงุณู
ุงูู
ูู:"); UIManager.put("FileChooser.filesOfTypeLabelText", " ููุน ุงูู
ูู:"); UIManager.put("FileChooser.detailsViewButtonToolTipText", "ุชูุงุตูู"); UIManager.put("FileChooser.upFolderToolTipText", "ููุฃุนูู") chooser = new MyFileChooser("aaa", "ุงูุนููุงู"); chooser.setAcceptAllFileFilterUsed(false); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); chooser.setFileHidingEnabled(false); pack(); setLocationRelativeTo(null); setVisible(true); setResizable(false); } public void actionPerformed(ActionEvent e) { if(e.getActionCommand().equals("myButton")) { int status = chooser.showOpenDialog(null);
ScreenShots:


Everything is cool, except for some parts that I need to change so that I can get the Arabic JFileChooser:
- The scroll bar is always set to the left when list view is on. How can i fix this?
- In the Details view, the table title is written in English. How to change it or at least turn off viewing of information?
- Shortcuts "Recent Items", "Desktop", "My Documents", "Computer" and "Network", how can I change them or at least delete them?
source share