Java Code Examples for com.apple.jobjc.foundation.NSAutoreleasePool

The following examples show how to use com.apple.jobjc.foundation.NSAutoreleasePool. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: dragonwell8_jdk   Source File: GUIDemo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args){
    JObjCRuntime.getInstance().registerUserClass(MyDelegate.class, MyDelegateClass.class);

    objc.AppKit().NSApplication().sharedApplication();
    NSApplication app = objc.AppKit().NSApp();

    NSAutoreleasePool pool = objc.Foundation().NSAutoreleasePool().alloc();
    pool = pool.init();
    app.setDelegate(new MyDelegateClass(JObjCRuntime.getInstance()).newID());
    app.run();
    pool.drain();
}
 
Example 2
Source Project: TencentKona-8   Source File: GUIDemo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args){
    JObjCRuntime.getInstance().registerUserClass(MyDelegate.class, MyDelegateClass.class);

    objc.AppKit().NSApplication().sharedApplication();
    NSApplication app = objc.AppKit().NSApp();

    NSAutoreleasePool pool = objc.Foundation().NSAutoreleasePool().alloc();
    pool = pool.init();
    app.setDelegate(new MyDelegateClass(JObjCRuntime.getInstance()).newID());
    app.run();
    pool.drain();
}
 
Example 3
Source Project: jdk8u60   Source File: GUIDemo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args){
    JObjCRuntime.getInstance().registerUserClass(MyDelegate.class, MyDelegateClass.class);

    objc.AppKit().NSApplication().sharedApplication();
    NSApplication app = objc.AppKit().NSApp();

    NSAutoreleasePool pool = objc.Foundation().NSAutoreleasePool().alloc();
    pool = pool.init();
    app.setDelegate(new MyDelegateClass(JObjCRuntime.getInstance()).newID());
    app.run();
    pool.drain();
}
 
Example 4
Source Project: openjdk-jdk8u   Source File: GUIDemo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args){
    JObjCRuntime.getInstance().registerUserClass(MyDelegate.class, MyDelegateClass.class);

    objc.AppKit().NSApplication().sharedApplication();
    NSApplication app = objc.AppKit().NSApp();

    NSAutoreleasePool pool = objc.Foundation().NSAutoreleasePool().alloc();
    pool = pool.init();
    app.setDelegate(new MyDelegateClass(JObjCRuntime.getInstance()).newID());
    app.run();
    pool.drain();
}
 
Example 5
Source Project: openjdk-jdk8u-backup   Source File: GUIDemo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args){
    JObjCRuntime.getInstance().registerUserClass(MyDelegate.class, MyDelegateClass.class);

    objc.AppKit().NSApplication().sharedApplication();
    NSApplication app = objc.AppKit().NSApp();

    NSAutoreleasePool pool = objc.Foundation().NSAutoreleasePool().alloc();
    pool = pool.init();
    app.setDelegate(new MyDelegateClass(JObjCRuntime.getInstance()).newID());
    app.run();
    pool.drain();
}
 
Example 6
Source Project: jdk8u-jdk   Source File: GUIDemo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args){
    JObjCRuntime.getInstance().registerUserClass(MyDelegate.class, MyDelegateClass.class);

    objc.AppKit().NSApplication().sharedApplication();
    NSApplication app = objc.AppKit().NSApp();

    NSAutoreleasePool pool = objc.Foundation().NSAutoreleasePool().alloc();
    pool = pool.init();
    app.setDelegate(new MyDelegateClass(JObjCRuntime.getInstance()).newID());
    app.run();
    pool.drain();
}
 
Example 7
Source Project: hottub   Source File: GUIDemo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args){
    JObjCRuntime.getInstance().registerUserClass(MyDelegate.class, MyDelegateClass.class);

    objc.AppKit().NSApplication().sharedApplication();
    NSApplication app = objc.AppKit().NSApp();

    NSAutoreleasePool pool = objc.Foundation().NSAutoreleasePool().alloc();
    pool = pool.init();
    app.setDelegate(new MyDelegateClass(JObjCRuntime.getInstance()).newID());
    app.run();
    pool.drain();
}
 
Example 8
Source Project: openjdk-8-source   Source File: GUIDemo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args){
    JObjCRuntime.getInstance().registerUserClass(MyDelegate.class, MyDelegateClass.class);

    objc.AppKit().NSApplication().sharedApplication();
    NSApplication app = objc.AppKit().NSApp();

    NSAutoreleasePool pool = objc.Foundation().NSAutoreleasePool().alloc();
    pool = pool.init();
    app.setDelegate(new MyDelegateClass(JObjCRuntime.getInstance()).newID());
    app.run();
    pool.drain();
}
 
Example 9
Source Project: openjdk-8   Source File: GUIDemo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args){
    JObjCRuntime.getInstance().registerUserClass(MyDelegate.class, MyDelegateClass.class);

    objc.AppKit().NSApplication().sharedApplication();
    NSApplication app = objc.AppKit().NSApp();

    NSAutoreleasePool pool = objc.Foundation().NSAutoreleasePool().alloc();
    pool = pool.init();
    app.setDelegate(new MyDelegateClass(JObjCRuntime.getInstance()).newID());
    app.run();
    pool.drain();
}
 
Example 10
Source Project: jdk8u_jdk   Source File: GUIDemo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args){
    JObjCRuntime.getInstance().registerUserClass(MyDelegate.class, MyDelegateClass.class);

    objc.AppKit().NSApplication().sharedApplication();
    NSApplication app = objc.AppKit().NSApp();

    NSAutoreleasePool pool = objc.Foundation().NSAutoreleasePool().alloc();
    pool = pool.init();
    app.setDelegate(new MyDelegateClass(JObjCRuntime.getInstance()).newID());
    app.run();
    pool.drain();
}
 
Example 11
Source Project: jdk8u-jdk   Source File: GUIDemo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args){
    JObjCRuntime.getInstance().registerUserClass(MyDelegate.class, MyDelegateClass.class);

    objc.AppKit().NSApplication().sharedApplication();
    NSApplication app = objc.AppKit().NSApp();

    NSAutoreleasePool pool = objc.Foundation().NSAutoreleasePool().alloc();
    pool = pool.init();
    app.setDelegate(new MyDelegateClass(JObjCRuntime.getInstance()).newID());
    app.run();
    pool.drain();
}
 
Example 12
Source Project: jdk8u-dev-jdk   Source File: GUIDemo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args){
    JObjCRuntime.getInstance().registerUserClass(MyDelegate.class, MyDelegateClass.class);

    objc.AppKit().NSApplication().sharedApplication();
    NSApplication app = objc.AppKit().NSApp();

    NSAutoreleasePool pool = objc.Foundation().NSAutoreleasePool().alloc();
    pool = pool.init();
    app.setDelegate(new MyDelegateClass(JObjCRuntime.getInstance()).newID());
    app.run();
    pool.drain();
}
 
Example 13
@Override public void setUp() throws Exception {
    FoundationFramework foundation = JObjC.getInstance().Foundation();
    pool = foundation.NSAutoreleasePool().alloc();
    pool.init();
}
 
Example 14
Source Project: dragonwell8_jdk   Source File: IntroTest.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }
 
Example 15
Source Project: TencentKona-8   Source File: PooledTestCase.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override public void setUp() throws Exception {
    FoundationFramework foundation = JObjC.getInstance().Foundation();
    pool = foundation.NSAutoreleasePool().alloc();
    pool.init();
}
 
Example 16
Source Project: TencentKona-8   Source File: IntroTest.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }
 
Example 17
Source Project: jdk8u60   Source File: PooledTestCase.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override public void setUp() throws Exception {
    FoundationFramework foundation = JObjC.getInstance().Foundation();
    pool = foundation.NSAutoreleasePool().alloc();
    pool.init();
}
 
Example 18
Source Project: jdk8u60   Source File: IntroTest.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }
 
Example 19
Source Project: openjdk-jdk8u   Source File: PooledTestCase.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override public void setUp() throws Exception {
    FoundationFramework foundation = JObjC.getInstance().Foundation();
    pool = foundation.NSAutoreleasePool().alloc();
    pool.init();
}
 
Example 20
Source Project: openjdk-jdk8u   Source File: IntroTest.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }
 
Example 21
@Override public void setUp() throws Exception {
    FoundationFramework foundation = JObjC.getInstance().Foundation();
    pool = foundation.NSAutoreleasePool().alloc();
    pool.init();
}
 
Example 22
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }
 
Example 23
Source Project: jdk8u-jdk   Source File: PooledTestCase.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override public void setUp() throws Exception {
    FoundationFramework foundation = JObjC.getInstance().Foundation();
    pool = foundation.NSAutoreleasePool().alloc();
    pool.init();
}
 
Example 24
Source Project: jdk8u-jdk   Source File: IntroTest.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }
 
Example 25
Source Project: hottub   Source File: PooledTestCase.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override public void setUp() throws Exception {
    FoundationFramework foundation = JObjC.getInstance().Foundation();
    pool = foundation.NSAutoreleasePool().alloc();
    pool.init();
}
 
Example 26
Source Project: hottub   Source File: IntroTest.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }
 
Example 27
@Override public void setUp() throws Exception {
    FoundationFramework foundation = JObjC.getInstance().Foundation();
    pool = foundation.NSAutoreleasePool().alloc();
    pool.init();
}
 
Example 28
Source Project: openjdk-8-source   Source File: IntroTest.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }
 
Example 29
Source Project: openjdk-8   Source File: PooledTestCase.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override public void setUp() throws Exception {
    FoundationFramework foundation = JObjC.getInstance().Foundation();
    pool = foundation.NSAutoreleasePool().alloc();
    pool.init();
}
 
Example 30
Source Project: openjdk-8   Source File: IntroTest.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }