• 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
Re: Problem creating an NSButton subclass in Java
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem creating an NSButton subclass in Java


  • Subject: Re: Problem creating an NSButton subclass in Java
  • From: Tom Sutcliffe <email@hidden>
  • Date: Sat, 2 Aug 2003 12:34:11 +0100

I'm trying to subclass an NSButton in my program with a Java class, so I've picked NSButton in IB, subclassed it, clicked the button in my form, set the custom class property to my new subclass, and created the file
for my new class. (Did I miss anything?)

For whatever reason, my program won't run when my subclass is set at the button's custom class. I get this cryptic console error:

jobjc_jvm_newObject(): constructor with signature (Ljava/io/InputStream;)V on class java/io/ObjectInputStream failed (should morph the java exception)

I don't know what this is referring to, as I don't use the java.io.ObjectInputStream class. Am I missing a step in my above procedure? Thanks for any help.

You've run into a problem when subclassing any object that goes through the java bridge. Basically you have to define a no-arguments constructor in your subclass. It's to do with how the NSArchiving of stuff in IB works, if you don't define this method the runtime can't instantiate your class.

public class MyButton extends NSButton {
public MyButton() {
super(); // Need to call this
// Otherwise you can leave this blank.
}
}

Happy subclassing,

Tom
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Problem creating an NSButton subclass in Java
      • From: Chris Backas <email@hidden>
References: 
 >Problem creating an NSButton subclass in Java (From: Chris Backas <email@hidden>)

  • Prev by Date: custom NSTextField issue
  • Next by Date: NSTableView Question
  • Previous by thread: Problem creating an NSButton subclass in Java
  • Next by thread: Re: Problem creating an NSButton subclass in Java
  • Index(es):
    • Date
    • Thread