Examples of NSOpenPanel


Examples of org.rococoa.cocoa.appkit.NSOpenPanel

    // Requires user to select a text file somewhere downtree from ~
    @Test
    @Ignore
    public void testShow() {
        new JFrame().setVisible(true); // otherwise no panel
        NSOpenPanel panel = NSOpenPanel.CLASS.openPanel();
       
        // Keep this reference!
        ObjCObject ocProxy = Rococoa.proxy(new Object() {
            @SuppressWarnings("unused")
            public boolean panel_shouldShowFilename(ID panel, String filename) {
                char initialChar = new File(filename).getName().toLowerCase().charAt(0);
                return initialChar % 2 == 0;
            }
        });
       
        panel.setDelegate(ocProxy.id());
        int button = panel.runModalForTypes(null);
//              or, eg       
//                NSArray.CLASS.arrayWithObjects(
//                    NSString.stringWithString("txt"), null));
        NSString filenameAsNSString = panel.filename();
        if (button == NSOpenPanel.NSOKButton) {
            assertTrue(filenameAsNSString.toString().startsWith("/Users"));
        } else {
            assertEquals(NSOpenPanel.NSCancelButton, button);
            assertNull(filenameAsNSString);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.