Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4301193

swing.JWindow(GraphicsConfiguration) throws unexpected IllegalArgumentException

XMLWordPrintable



      Name: aaC67449 Date: 12/22/99


      The constructor swing.JWindow(GraphicsConfiguration) always throws
      IllegalArgumentException

      See example.
      ------------------------- example ----------------
      import javax.swing.JWindow;
      import java.awt.*;
      import java.awt.geom.AffineTransform;
      import java.awt.image.BufferedImage;
      import java.awt.image.ColorModel;

      public class Test {

          public static void main(String argv[]) {
              GraphicsConfiguration test = new StubGraphicsConfiguration();
              JWindow w = new JWindow(test);
              System.out.println("Ok");
       
         }

      }


      class StubGraphicsConfiguration extends GraphicsConfiguration {
          public StubGraphicsConfiguration() {
          }
          
          public GraphicsDevice getDevice(){
              return new StubGraphicsDevice();
          }

          public BufferedImage createCompatibleImage(int width, int height){
              return null;
          }
          
          public BufferedImage createCompatibleImage(int width, int height,
                                                              int transparency){
              return null;
          }

          public ColorModel getColorModel(){
              return null;
          }

          public ColorModel getColorModel(int transparency){
              return null;
          }

          public AffineTransform getDefaultTransform(){
              return null;
          }

          public AffineTransform getNormalizingTransform(){
              return null;
          }

          public Rectangle getBounds(){
              return new Rectangle(100,100,100,100);
          }

      }


      class StubGraphicsDevice extends GraphicsDevice {
       
          public StubGraphicsDevice() {
          }
          
          public int getType() {
              return TYPE_RASTER_SCREEN;
          }

          public String getIDstring() {
              return "Test";
          }

          public GraphicsConfiguration[] getConfigurations() {
              GraphicsConfiguration gc[]={new StubGraphicsConfiguration()};
              return gc;
          }

          public GraphicsConfiguration getDefaultConfiguration(){
              return new StubGraphicsConfiguration();
          }
      }
      ------------------------- output ----------------
      Exception in thread "main" java.lang.IllegalArgumentException: null owner window
              at java.awt.Window.ownedInit(Window.java:300)
              at java.awt.Window.<init>(Window.java:295)
              at javax.swing.JWindow.<init>(JWindow.java:160)
              at javax.swing.JWindow.<init>(JWindow.java:124)
              at Test.main(Test.java:11)

      ======================================================================

            amfowler Anne Fowler (Inactive)
            alisunw Ali Ali (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: