• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Calling a JFrame from a nib file...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Calling a JFrame from a nib file...


  • Subject: Calling a JFrame from a nib file...
  • From: "François GOURAND" <email@hidden>
  • Date: Mon, 26 Nov 2001 18:53:02 +0100

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


  • Follow-Ups:
    • Re: Calling a JFrame from a nib file...
      • From: Russ White <email@hidden>
  • Prev by Date: NSSmallControlSize in programatically creating an NSPopUpButtonCell?
  • Next by Date: NSTextField cuts lines
  • Previous by thread: Re: NSSmallControlSize in programatically creating an NSPopUpButtonCell?
  • Next by thread: Re: Calling a JFrame from a nib file...
  • Index(es):
    • Date
    • Thread