Results 1 to 7 of 7

Thread: Calling

  1. #1
    Dissonance is offline Programming Again
    Join Date
    May 2012
    Location
    Eugene, OR
    Posts
    55
    Rep Power
    0

    Default Calling

    Hello!

    I'm using an open source library called JMusic, and I can get it to do what I want with the NetBeans applet viewer; however, I can't get it to display in my applet. I've gone through all the examples I could find, and they all do something different than what I'm trying to do. As far as I can tell, the library has a class that extends java.awt.Frame for this purpose. I can attach the notation to this class with its constructor, but I can't display the class inside my applet because it (ss below) pops up in a new window.

    Score s = new Score();
    ShowScore ss = new ShowScore(s);
    panel.add(ss);

    (panel is a JPanel)

    Would someone please make a suggestion?

    Thanks!

  2. #2
    Dissonance is offline Programming Again
    Join Date
    May 2012
    Location
    Eugene, OR
    Posts
    55
    Rep Power
    0

    Default Re: Calling

    I also tried a JInternalFrame and I get

    java.lang.IllegalArgumentException: adding a window to a container

  3. #3
    Dissonance is offline Programming Again
    Join Date
    May 2012
    Location
    Eugene, OR
    Posts
    55
    Rep Power
    0

    Default Re: Calling

    Oops! I forgot to completely fill in the subject.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: Calling

    In a JApplet subclass's init() method:
    Java Code:
    setContentPane(frame.getContentPane());
    I forgot to completely fill in the subject.
    YOu can edit the first post (click 'Go Advanced') and update the subject line.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    Dissonance is offline Programming Again
    Join Date
    May 2012
    Location
    Eugene, OR
    Posts
    55
    Rep Power
    0

    Default Displaying class from open-source library in InternalFrame

    Quote Originally Posted by DarrylBurke View Post
    In a JApplet subclass's init() method:
    Java Code:
    setContentPane(frame.getContentPane());
    That didn't quite work for me, but I was able to figure it out using it as a starting place. As far as I can tell, the library's ShowScore class will always open in a new window. I discovered that some other classes in the library would work when cast to Component. In the applet's init():

    Java Code:
    ts = new TrebleStave(doStuff());
    c = (Component)ts;
    musicInternalFrame.getContentPane().add(c);
    I learned that I can hide the title bar with this:

    Java Code:
    ((javax.swing.plaf.basic.BasicInternalFrameUI) musicInternalFrame.getUI()).setNorthPane(null);
    db, thanks for helping me solve this!

  6. #6
    Dissonance is offline Programming Again
    Join Date
    May 2012
    Location
    Eugene, OR
    Posts
    55
    Rep Power
    0

    Default Re: Displaying class from open-source library in InternalFrame

    I can add the component to the JInternalFrame from the applet's init. Is there any way I can change the component after the applet is running? I can remove the component with

    musicInternalFrame.removeAll();

    but I can't seem to add another component once the applet is started.

  7. #7
    Dissonance is offline Programming Again
    Join Date
    May 2012
    Location
    Eugene, OR
    Posts
    55
    Rep Power
    0

    Default Re: Displaying class from open-source library in InternalFrame

    I must've been doing something wrong, but it's working now.

    Java Code:
    BassStave bs = new BassStave(doStuff());
    musicInternalFrame.remove(c);
    c = (Component)bs;
    musicInternalFrame.getContentPane().add(c);

Similar Threads

  1. calling a JSP from a JSP
    By ajincoep in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 02-02-2011, 09:31 AM
  2. Calling swt shells one after another
    By Maja in forum SWT / JFace
    Replies: 1
    Last Post: 10-18-2010, 01:36 PM
  3. calling servlet from jsp
    By sameerk in forum JavaServer Pages (JSP) and JSTL
    Replies: 6
    Last Post: 09-21-2010, 07:04 AM
  4. Calling an Object
    By 67726e in forum New To Java
    Replies: 8
    Last Post: 08-10-2010, 01:49 AM
  5. help calling 1 .java from another.
    By New-to-this in forum New To Java
    Replies: 1
    Last Post: 08-14-2009, 04:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •