jdic
  1. jdic
  2. JDIC-64

SimpleScreensaver.setComponenet doesn't seem to work

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 0.8.4
    • Fix Version/s: None
    • Component/s: Screensavers
    • Labels:
      None
    • Environment:

      Operating System: Windows XP
      Platform: All

    • Issuezilla Id:
      64

      Description

      There are many cases where it would be advantageous to replace the supplied
      renderable component with a custom one, such as a JFrame or a JOGL based
      component. The trailing code attempts to do this. Rather than calling the
      appropriate function on the new Container (as expected), the code simply fails
      (the Graphics object is null).

      Is the sample performing the replacement incorrectly, or is the code not
      designed to receive a different default Container? If not, should this feature
      be added?

      Here is the sample:

      /*

      • Created on Jul 20, 2004
        */
        package ss;

      import java.awt.*;
      import javax.swing.*;
      import org.jdesktop.jdic.screensaver.*;

      /**

      • @author Mark Bastian
        *
        */
        public class MyScreenSaver2 extends SimpleScreensaver
        {
        public static void main(String[] args) { ScreensaverFrame ssf = new ScreensaverFrame(new MyScreenSaver2 (), ""); ssf.show(); }

      /* (non-Javadoc)

      • @see org.jdesktop.jdic.screensaver.ScreensaverBase#init()
        */
        protected void init() { super.init(); this.getContext().setComponent(new MyPanel()); }

      private class MyPanel extends JPanel
      {
      public void paint(Graphics arg0)

      { this.setBackground(Color.WHITE); super.paint(arg0); }

      }

      public void paint(Graphics arg0)

      { System.out.println(arg0); }

      }

        Activity

        Hide
        markroth8 added a comment -

        The setComponent() method is not intended to be called by the screensaver. It
        is given to you by the system so that you can draw your screensaver. Different
        platforms will have different instances of this component available.

        I'll clarify this in the javadocs.

        In all the implementations of ScreensaverBase thus far, the Component also
        happens to be a Container. If you're feeling adventurous, you can cheat and
        cast the Component to a Container so that you can add your own InternalFrame or
        your own Panel. However, this is not guaranteed, and there may be platforms
        where this is not possible, in the future (e.g. we haven't done our Mac binding
        yet, contributions welcome).

        You mentioned JOGL - please join the forums on
        https://screensavers.dev.java.net/ I am currently working on built-in support
        for JOGL in the next release of the SaverBeans SDK. The work is mostly done.

        Show
        markroth8 added a comment - The setComponent() method is not intended to be called by the screensaver. It is given to you by the system so that you can draw your screensaver. Different platforms will have different instances of this component available. I'll clarify this in the javadocs. In all the implementations of ScreensaverBase thus far, the Component also happens to be a Container. If you're feeling adventurous, you can cheat and cast the Component to a Container so that you can add your own InternalFrame or your own Panel. However, this is not guaranteed, and there may be platforms where this is not possible, in the future (e.g. we haven't done our Mac binding yet, contributions welcome). You mentioned JOGL - please join the forums on https://screensavers.dev.java.net/ I am currently working on built-in support for JOGL in the next release of the SaverBeans SDK. The work is mostly done.

          People

          • Assignee:
            markroth8
            Reporter:
            jeeky
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: