Re: Calling a JFrame from a nib file...
Re: Calling a JFrame from a nib file...
- Subject: Re: Calling a JFrame from a nib file...
- From: Russ White <email@hidden>
- Date: Wed, 28 Nov 2001 06:00:10 -0800
Unfortunately, you can't mix Swing & Cocoa (or even AWT & Cocoa).
"The Cocoa application environment includes Java packages corresponding
to the Application Kit and Foundation frameworks. These packages allow
you to develop a Cocoa application using Java as the development
language. You can mix (within reason) the APIs from these packages and
native Java APIs (excluding AWT or Swing APIs)."
See Link:
http://developer.apple.com/techpubs/macosx/Essentials/SystemOverview/SystemArchitecture/
Application_Environments.html
Yes, it's a bummer.
On Monday, November 26, 2001, at 09:53 AM, Frangois GOURAND wrote:
Hi everybody,
I'm quite stuck with this annoying problem for a while, I hope someone
will
be able to give me some help ! :-)
Basically, what I'm going to do is :
- create a Cocoa/Java project type first (OK !!)
- add a button to the MainMenu.nib file whose label is "Connect", which
calls the clicked Java method (its action...)
- In this clicked method, I also call a display method from a Java
Windowt
class which is just supposed to display a JFrame...
Here's the code :
Windowt.java
---------------------------------------
import java.util.*;
import javax.swing.*;
public class Windowt {
public void Windowt () {}
public static void display() {
System.out.println("Step 1");
JFrame myFrame = new JFrame("It's my frame !");
System.out.println("Step 2");
myFrame.show();
}
}
----------------------------------------
ClickIt.java
---------------------------------------
import com.apple.cocoa.foundation.*;
import com.apple.cocoa.application.*;
public class ClickIt extends NSObject {
NSButton connecte;
public void clicked(NSButton sender) {
System.out.println("You clicked the button");
Windowt.display();
}
}
--------------------------------------------
So, as you can see, it's quite simple, but when I run it, when I click
the
button, I get on the console log :
You clicked the button
Step 1
and then nothing happens... (no JFrame at all...)
Could you explain me why ?
Is it a simple question of compatibility between Swing and the Cocoa
Framework ?
My final goal is to make a Cocoa/java application, because I have some
parts
of this application written in Cocoa, which I need to link with all the
Java
stuff (and especially the home window of the application... which is a
JFrame...)
If you know another way to make this link, please let me know
That's why I need to link these 2 parts !
Thanks a lot for your help,
regards,
Frangois Gourand
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev