FileDocCategorySizeDatePackage
ContextMenuFileChooser.javaAPI DocExample2543Mon Jan 09 11:01:58 GMT 2006None

ContextMenuFileChooser

public class ContextMenuFileChooser extends JFileChooser

Fields Summary
protected Component
right_click_pane
Constructors Summary
public ContextMenuFileChooser()

        super();

        JPopupMenu popup = new JPopupMenu();
        popup.add(new DeleteAction(this));
        popup.add(new NewFolderAction(this));
        popup.setLightWeightPopupEnabled(false);
        
        right_click_pane = new RightClickGlassPane(this,popup) {
            protected void redispatchMouseEvent(MouseEvent e, boolean repaint) {
                Component component = getRealComponent(e.getPoint());
                if(component == null) { return; }
                String chooser_class = "javax.swing.plaf.metal.MetalFileChooserUI$5";
                if(component.getClass().getName().equals(chooser_class)) {
                    super.redispatchMouseEvent(e,repaint);
                } else {
                    doDispatch(e);
                }
            }
        };
        
        setFileSelectionMode(FILES_AND_DIRECTORIES);
    
Methods Summary
protected javax.swing.JDialogcreateDialog(java.awt.Component parent)

        JDialog dialog = super.createDialog(parent);
        
        // create the right click glass pane.
        dialog.setGlassPane(right_click_pane);
        right_click_pane.setVisible(true);
        
        return dialog;
    
public static voidmain(java.lang.String[] args)

        final JFileChooser jfc = new ContextMenuFileChooser();
        jfc.showOpenDialog(null);
        System.exit(0);
    
public static voidp(java.lang.String str)

        System.out.println(str);