< prev index next >

src/java.desktop/share/classes/java/awt/Window.java

Print this page




 738      * @see       #getIconImages()
 739      * @since     1.6
 740      */
 741     public void setIconImage(Image image) {
 742         ArrayList<Image> imageList = new ArrayList<Image>();
 743         if (image != null) {
 744             imageList.add(image);
 745         }
 746         setIconImages(imageList);
 747     }
 748 
 749     /**
 750      * Makes this Window displayable by creating the connection to its
 751      * native screen resource.
 752      * This method is called internally by the toolkit and should
 753      * not be called directly by programs.
 754      * @see Component#isDisplayable
 755      * @see Container#removeNotify
 756      * @since 1.0
 757      */

 758     public void addNotify() {
 759         synchronized (getTreeLock()) {
 760             Container parent = this.parent;
 761             if (parent != null && parent.getPeer() == null) {
 762                 parent.addNotify();
 763             }
 764             if (peer == null) {
 765                 peer = getToolkit().createWindow(this);
 766             }
 767             synchronized (allWindows) {
 768                 allWindows.add(this);
 769             }
 770             super.addNotify();
 771         }
 772     }
 773 
 774     /**
 775      * {@inheritDoc}
 776      */
 777     public void removeNotify() {


 781             }
 782             super.removeNotify();
 783         }
 784     }
 785 
 786     /**
 787      * Causes this Window to be sized to fit the preferred size
 788      * and layouts of its subcomponents. The resulting width and
 789      * height of the window are automatically enlarged if either
 790      * of dimensions is less than the minimum size as specified
 791      * by the previous call to the {@code setMinimumSize} method.
 792      * <p>
 793      * If the window and/or its owner are not displayable yet,
 794      * both of them are made displayable before calculating
 795      * the preferred size. The Window is validated after its
 796      * size is being calculated.
 797      *
 798      * @see Component#isDisplayable
 799      * @see #setMinimumSize
 800      */

 801     public void pack() {
 802         Container parent = this.parent;
 803         if (parent != null && parent.getPeer() == null) {
 804             parent.addNotify();
 805         }
 806         if (peer == null) {
 807             addNotify();
 808         }
 809         Dimension newSize = getPreferredSize();
 810         if (peer != null) {
 811             setClientSize(newSize.width, newSize.height);
 812         }
 813 
 814         if(beforeFirstShow) {
 815             isPacked = true;
 816         }
 817 
 818         validateUnconditionally();
 819     }
 820 


1053             if (!isModalBlocked()) {
1054                 updateChildrenBlocking();
1055             } else {
1056                 // fix for 6532736: after this window is shown, its blocker
1057                 // should be raised to front
1058                 modalBlocker.toFront_NoClientCode();
1059             }
1060             if (this instanceof Frame || this instanceof Dialog) {
1061                 updateChildFocusableWindowState(this);
1062             }
1063         }
1064         isInShow = false;
1065 
1066         // If first time shown, generate WindowOpened event
1067         if ((state & OPENED) == 0) {
1068             postWindowEvent(WindowEvent.WINDOW_OPENED);
1069             state |= OPENED;
1070         }
1071     }
1072 

1073     static void updateChildFocusableWindowState(Window w) {
1074         if (w.getPeer() != null && w.isShowing()) {
1075             ((WindowPeer)w.getPeer()).updateFocusableWindowState();
1076         }
1077         for (int i = 0; i < w.ownedWindowList.size(); i++) {
1078             Window child = w.ownedWindowList.elementAt(i).get();
1079             if (child != null) {
1080                 updateChildFocusableWindowState(child);
1081             }
1082         }
1083     }
1084 
1085     synchronized void postWindowEvent(int id) {
1086         if (windowListener != null
1087             || (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0
1088             ||  Toolkit.enabledOnToolkit(AWTEvent.WINDOW_EVENT_MASK)) {
1089             WindowEvent e = new WindowEvent(this, id);
1090             Toolkit.getEventQueue().postEvent(e);
1091         }
1092     }


1140      * those actions).
1141      * <p>
1142      * <b>Note</b>: When the last displayable window
1143      * within the Java virtual machine (VM) is disposed of, the VM may
1144      * terminate.  See <a href="doc-files/AWTThreadIssues.html#Autoshutdown">
1145      * AWT Threading Issues</a> for more information.
1146      * @see Component#isDisplayable
1147      * @see #pack
1148      * @see #show
1149      */
1150     public void dispose() {
1151         doDispose();
1152     }
1153 
1154     /*
1155      * Fix for 4872170.
1156      * If dispose() is called on parent then its children have to be disposed as well
1157      * as reported in javadoc. So we need to implement this functionality even if a
1158      * child overrides dispose() in a wrong way without calling super.dispose().
1159      */

1160     void disposeImpl() {
1161         dispose();
1162         if (getPeer() != null) {
1163             doDispose();
1164         }
1165     }
1166 
1167     void doDispose() {
1168     class DisposeAction implements Runnable {
1169         public void run() {
1170             disposing = true;
1171             try {
1172                 // Check if this window is the fullscreen window for the
1173                 // device. Exit the fullscreen mode prior to disposing
1174                 // of the window if that's the case.
1175                 GraphicsDevice gd = getGraphicsConfiguration().getDevice();
1176                 if (gd.getFullScreenWindow() == Window.this) {
1177                     gd.setFullScreenWindow(null);
1178                 }
1179 


3606      *     [0..1]
3607      * @throws IllegalComponentStateException if the window is decorated and
3608      *     the opacity is less than {@code 1.0f}
3609      * @throws IllegalComponentStateException if the window is in full screen
3610      *     mode, and the opacity is less than {@code 1.0f}
3611      * @throws UnsupportedOperationException if the {@code
3612      *     GraphicsDevice.WindowTranslucency#TRANSLUCENT TRANSLUCENT}
3613      *     translucency is not supported and the opacity is less than
3614      *     {@code 1.0f}
3615      *
3616      * @see Window#getOpacity
3617      * @see Window#setBackground(Color)
3618      * @see Window#setShape(Shape)
3619      * @see Frame#isUndecorated
3620      * @see Dialog#isUndecorated
3621      * @see GraphicsDevice.WindowTranslucency
3622      * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
3623      *
3624      * @since 1.7
3625      */

3626     public void setOpacity(float opacity) {
3627         synchronized (getTreeLock()) {
3628             if (opacity < 0.0f || opacity > 1.0f) {
3629                 throw new IllegalArgumentException(
3630                     "The value of opacity should be in the range [0.0f .. 1.0f].");
3631             }
3632             if (opacity < 1.0f) {
3633                 GraphicsConfiguration gc = getGraphicsConfiguration();
3634                 GraphicsDevice gd = gc.getDevice();
3635                 if (gc.getDevice().getFullScreenWindow() == this) {
3636                     throw new IllegalComponentStateException(
3637                         "Setting opacity for full-screen window is not supported.");
3638                 }
3639                 if (!gd.isWindowTranslucencySupported(
3640                     GraphicsDevice.WindowTranslucency.TRANSLUCENT))
3641                 {
3642                     throw new UnsupportedOperationException(
3643                         "TRANSLUCENT translucency is not supported.");
3644                 }
3645             }


3704      * @param shape the shape to set to the window
3705      *
3706      * @throws IllegalComponentStateException if the shape is not {@code
3707      *     null} and the window is decorated
3708      * @throws IllegalComponentStateException if the shape is not {@code
3709      *     null} and the window is in full-screen mode
3710      * @throws UnsupportedOperationException if the shape is not {@code
3711      *     null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
3712      *     PERPIXEL_TRANSPARENT} translucency is not supported
3713      *
3714      * @see Window#getShape()
3715      * @see Window#setBackground(Color)
3716      * @see Window#setOpacity(float)
3717      * @see Frame#isUndecorated
3718      * @see Dialog#isUndecorated
3719      * @see GraphicsDevice.WindowTranslucency
3720      * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
3721      *
3722      * @since 1.7
3723      */

3724     public void setShape(Shape shape) {
3725         synchronized (getTreeLock()) {
3726             if (shape != null) {
3727                 GraphicsConfiguration gc = getGraphicsConfiguration();
3728                 GraphicsDevice gd = gc.getDevice();
3729                 if (gc.getDevice().getFullScreenWindow() == this) {
3730                     throw new IllegalComponentStateException(
3731                         "Setting shape for full-screen window is not supported.");
3732                 }
3733                 if (!gd.isWindowTranslucencySupported(
3734                         GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
3735                 {
3736                     throw new UnsupportedOperationException(
3737                         "PERPIXEL_TRANSPARENT translucency is not supported.");
3738                 }
3739             }
3740             this.shape = (shape == null) ? null : new Path2D.Float(shape);
3741             WindowPeer peer = (WindowPeer)getPeer();
3742             if (peer != null) {
3743                 peer.applyShape(shape == null ? null : Region.getInstance(shape, null));


3821      *     background color is less than {@code 1.0f} and the window is decorated
3822      * @throws IllegalComponentStateException if the alpha value of the given
3823      *     background color is less than {@code 1.0f} and the window is in
3824      *     full-screen mode
3825      * @throws UnsupportedOperationException if the alpha value of the given
3826      *     background color is less than {@code 1.0f} and {@link
3827      *     GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT
3828      *     PERPIXEL_TRANSLUCENT} translucency is not supported
3829      *
3830      * @see Window#getBackground
3831      * @see Window#isOpaque
3832      * @see Window#setOpacity(float)
3833      * @see Window#setShape(Shape)
3834      * @see Frame#isUndecorated
3835      * @see Dialog#isUndecorated
3836      * @see GraphicsDevice.WindowTranslucency
3837      * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
3838      * @see GraphicsConfiguration#isTranslucencyCapable()
3839      */
3840     @Override

3841     public void setBackground(Color bgColor) {
3842         Color oldBg = getBackground();
3843         super.setBackground(bgColor);
3844         if (oldBg != null && oldBg.equals(bgColor)) {
3845             return;
3846         }
3847         int oldAlpha = oldBg != null ? oldBg.getAlpha() : 255;
3848         int alpha = bgColor != null ? bgColor.getAlpha() : 255;
3849         if ((oldAlpha == 255) && (alpha < 255)) { // non-opaque window
3850             GraphicsConfiguration gc = getGraphicsConfiguration();
3851             GraphicsDevice gd = gc.getDevice();
3852             if (gc.getDevice().getFullScreenWindow() == this) {
3853                 throw new IllegalComponentStateException(
3854                     "Making full-screen window non opaque is not supported.");
3855             }
3856             if (!gc.isTranslucencyCapable()) {
3857                 GraphicsConfiguration capableGC = gd.getTranslucencyCapableGC();
3858                 if (capableGC == null) {
3859                     throw new UnsupportedOperationException(
3860                         "PERPIXEL_TRANSLUCENT translucency is not supported");


3873 
3874     /**
3875      * Indicates if the window is currently opaque.
3876      * <p>
3877      * The method returns {@code false} if the background color of the window
3878      * is not {@code null} and the alpha component of the color is less than
3879      * {@code 1.0f}. The method returns {@code true} otherwise.
3880      *
3881      * @return {@code true} if the window is opaque, {@code false} otherwise
3882      *
3883      * @see Window#getBackground
3884      * @see Window#setBackground(Color)
3885      * @since 1.7
3886      */
3887     @Override
3888     public boolean isOpaque() {
3889         Color bg = getBackground();
3890         return bg != null ? bg.getAlpha() == 255 : true;
3891     }
3892 

3893     private void updateWindow() {
3894         synchronized (getTreeLock()) {
3895             WindowPeer peer = (WindowPeer)getPeer();
3896             if (peer != null) {
3897                 peer.updateWindow();
3898             }
3899         }
3900     }
3901 
3902     /**
3903      * {@inheritDoc}
3904      *
3905      * @since 1.7
3906      */
3907     @Override
3908     public void paint(Graphics g) {
3909         if (!isOpaque()) {
3910             Graphics gg = g.create();
3911             try {
3912                 if (gg instanceof Graphics2D) {


4063                     bg = new Color(0, 0, 0, 0);
4064                 }
4065                 window.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue(),
4066                                                opaque ? 255 : 0));
4067             }
4068             public void updateWindow(Window window) {
4069                 window.updateWindow();
4070             }
4071 
4072             public Dimension getSecurityWarningSize(Window window) {
4073                 return new Dimension(window.securityWarningWidth,
4074                         window.securityWarningHeight);
4075             }
4076 
4077             public void setSecurityWarningSize(Window window, int width, int height)
4078             {
4079                 window.securityWarningWidth = width;
4080                 window.securityWarningHeight = height;
4081             }
4082 

4083             public void setSecurityWarningPosition(Window window,
4084                     Point2D point, float alignmentX, float alignmentY)
4085             {
4086                 window.securityWarningPointX = point.getX();
4087                 window.securityWarningPointY = point.getY();
4088                 window.securityWarningAlignmentX = alignmentX;
4089                 window.securityWarningAlignmentY = alignmentY;
4090 
4091                 synchronized (window.getTreeLock()) {
4092                     WindowPeer peer = (WindowPeer)window.getPeer();
4093                     if (peer != null) {
4094                         peer.repositionSecurityWarning();
4095                     }
4096                 }
4097             }
4098 
4099             public Point2D calculateSecurityWarningPosition(Window window,
4100                     double x, double y, double w, double h)
4101             {
4102                 return window.calculateSecurityWarningPosition(x, y, w, h);




 738      * @see       #getIconImages()
 739      * @since     1.6
 740      */
 741     public void setIconImage(Image image) {
 742         ArrayList<Image> imageList = new ArrayList<Image>();
 743         if (image != null) {
 744             imageList.add(image);
 745         }
 746         setIconImages(imageList);
 747     }
 748 
 749     /**
 750      * Makes this Window displayable by creating the connection to its
 751      * native screen resource.
 752      * This method is called internally by the toolkit and should
 753      * not be called directly by programs.
 754      * @see Component#isDisplayable
 755      * @see Container#removeNotify
 756      * @since 1.0
 757      */
 758     @SuppressWarnings("deprecation")
 759     public void addNotify() {
 760         synchronized (getTreeLock()) {
 761             Container parent = this.parent;
 762             if (parent != null && parent.getPeer() == null) {
 763                 parent.addNotify();
 764             }
 765             if (peer == null) {
 766                 peer = getToolkit().createWindow(this);
 767             }
 768             synchronized (allWindows) {
 769                 allWindows.add(this);
 770             }
 771             super.addNotify();
 772         }
 773     }
 774 
 775     /**
 776      * {@inheritDoc}
 777      */
 778     public void removeNotify() {


 782             }
 783             super.removeNotify();
 784         }
 785     }
 786 
 787     /**
 788      * Causes this Window to be sized to fit the preferred size
 789      * and layouts of its subcomponents. The resulting width and
 790      * height of the window are automatically enlarged if either
 791      * of dimensions is less than the minimum size as specified
 792      * by the previous call to the {@code setMinimumSize} method.
 793      * <p>
 794      * If the window and/or its owner are not displayable yet,
 795      * both of them are made displayable before calculating
 796      * the preferred size. The Window is validated after its
 797      * size is being calculated.
 798      *
 799      * @see Component#isDisplayable
 800      * @see #setMinimumSize
 801      */
 802     @SuppressWarnings("deprecation")
 803     public void pack() {
 804         Container parent = this.parent;
 805         if (parent != null && parent.getPeer() == null) {
 806             parent.addNotify();
 807         }
 808         if (peer == null) {
 809             addNotify();
 810         }
 811         Dimension newSize = getPreferredSize();
 812         if (peer != null) {
 813             setClientSize(newSize.width, newSize.height);
 814         }
 815 
 816         if(beforeFirstShow) {
 817             isPacked = true;
 818         }
 819 
 820         validateUnconditionally();
 821     }
 822 


1055             if (!isModalBlocked()) {
1056                 updateChildrenBlocking();
1057             } else {
1058                 // fix for 6532736: after this window is shown, its blocker
1059                 // should be raised to front
1060                 modalBlocker.toFront_NoClientCode();
1061             }
1062             if (this instanceof Frame || this instanceof Dialog) {
1063                 updateChildFocusableWindowState(this);
1064             }
1065         }
1066         isInShow = false;
1067 
1068         // If first time shown, generate WindowOpened event
1069         if ((state & OPENED) == 0) {
1070             postWindowEvent(WindowEvent.WINDOW_OPENED);
1071             state |= OPENED;
1072         }
1073     }
1074 
1075     @SuppressWarnings("deprecation")
1076     static void updateChildFocusableWindowState(Window w) {
1077         if (w.getPeer() != null && w.isShowing()) {
1078             ((WindowPeer)w.getPeer()).updateFocusableWindowState();
1079         }
1080         for (int i = 0; i < w.ownedWindowList.size(); i++) {
1081             Window child = w.ownedWindowList.elementAt(i).get();
1082             if (child != null) {
1083                 updateChildFocusableWindowState(child);
1084             }
1085         }
1086     }
1087 
1088     synchronized void postWindowEvent(int id) {
1089         if (windowListener != null
1090             || (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0
1091             ||  Toolkit.enabledOnToolkit(AWTEvent.WINDOW_EVENT_MASK)) {
1092             WindowEvent e = new WindowEvent(this, id);
1093             Toolkit.getEventQueue().postEvent(e);
1094         }
1095     }


1143      * those actions).
1144      * <p>
1145      * <b>Note</b>: When the last displayable window
1146      * within the Java virtual machine (VM) is disposed of, the VM may
1147      * terminate.  See <a href="doc-files/AWTThreadIssues.html#Autoshutdown">
1148      * AWT Threading Issues</a> for more information.
1149      * @see Component#isDisplayable
1150      * @see #pack
1151      * @see #show
1152      */
1153     public void dispose() {
1154         doDispose();
1155     }
1156 
1157     /*
1158      * Fix for 4872170.
1159      * If dispose() is called on parent then its children have to be disposed as well
1160      * as reported in javadoc. So we need to implement this functionality even if a
1161      * child overrides dispose() in a wrong way without calling super.dispose().
1162      */
1163     @SuppressWarnings("deprecation")
1164     void disposeImpl() {
1165         dispose();
1166         if (getPeer() != null) {
1167             doDispose();
1168         }
1169     }
1170 
1171     void doDispose() {
1172     class DisposeAction implements Runnable {
1173         public void run() {
1174             disposing = true;
1175             try {
1176                 // Check if this window is the fullscreen window for the
1177                 // device. Exit the fullscreen mode prior to disposing
1178                 // of the window if that's the case.
1179                 GraphicsDevice gd = getGraphicsConfiguration().getDevice();
1180                 if (gd.getFullScreenWindow() == Window.this) {
1181                     gd.setFullScreenWindow(null);
1182                 }
1183 


3610      *     [0..1]
3611      * @throws IllegalComponentStateException if the window is decorated and
3612      *     the opacity is less than {@code 1.0f}
3613      * @throws IllegalComponentStateException if the window is in full screen
3614      *     mode, and the opacity is less than {@code 1.0f}
3615      * @throws UnsupportedOperationException if the {@code
3616      *     GraphicsDevice.WindowTranslucency#TRANSLUCENT TRANSLUCENT}
3617      *     translucency is not supported and the opacity is less than
3618      *     {@code 1.0f}
3619      *
3620      * @see Window#getOpacity
3621      * @see Window#setBackground(Color)
3622      * @see Window#setShape(Shape)
3623      * @see Frame#isUndecorated
3624      * @see Dialog#isUndecorated
3625      * @see GraphicsDevice.WindowTranslucency
3626      * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
3627      *
3628      * @since 1.7
3629      */
3630     @SuppressWarnings("deprecation")
3631     public void setOpacity(float opacity) {
3632         synchronized (getTreeLock()) {
3633             if (opacity < 0.0f || opacity > 1.0f) {
3634                 throw new IllegalArgumentException(
3635                     "The value of opacity should be in the range [0.0f .. 1.0f].");
3636             }
3637             if (opacity < 1.0f) {
3638                 GraphicsConfiguration gc = getGraphicsConfiguration();
3639                 GraphicsDevice gd = gc.getDevice();
3640                 if (gc.getDevice().getFullScreenWindow() == this) {
3641                     throw new IllegalComponentStateException(
3642                         "Setting opacity for full-screen window is not supported.");
3643                 }
3644                 if (!gd.isWindowTranslucencySupported(
3645                     GraphicsDevice.WindowTranslucency.TRANSLUCENT))
3646                 {
3647                     throw new UnsupportedOperationException(
3648                         "TRANSLUCENT translucency is not supported.");
3649                 }
3650             }


3709      * @param shape the shape to set to the window
3710      *
3711      * @throws IllegalComponentStateException if the shape is not {@code
3712      *     null} and the window is decorated
3713      * @throws IllegalComponentStateException if the shape is not {@code
3714      *     null} and the window is in full-screen mode
3715      * @throws UnsupportedOperationException if the shape is not {@code
3716      *     null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
3717      *     PERPIXEL_TRANSPARENT} translucency is not supported
3718      *
3719      * @see Window#getShape()
3720      * @see Window#setBackground(Color)
3721      * @see Window#setOpacity(float)
3722      * @see Frame#isUndecorated
3723      * @see Dialog#isUndecorated
3724      * @see GraphicsDevice.WindowTranslucency
3725      * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
3726      *
3727      * @since 1.7
3728      */
3729     @SuppressWarnings("deprecation")
3730     public void setShape(Shape shape) {
3731         synchronized (getTreeLock()) {
3732             if (shape != null) {
3733                 GraphicsConfiguration gc = getGraphicsConfiguration();
3734                 GraphicsDevice gd = gc.getDevice();
3735                 if (gc.getDevice().getFullScreenWindow() == this) {
3736                     throw new IllegalComponentStateException(
3737                         "Setting shape for full-screen window is not supported.");
3738                 }
3739                 if (!gd.isWindowTranslucencySupported(
3740                         GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
3741                 {
3742                     throw new UnsupportedOperationException(
3743                         "PERPIXEL_TRANSPARENT translucency is not supported.");
3744                 }
3745             }
3746             this.shape = (shape == null) ? null : new Path2D.Float(shape);
3747             WindowPeer peer = (WindowPeer)getPeer();
3748             if (peer != null) {
3749                 peer.applyShape(shape == null ? null : Region.getInstance(shape, null));


3827      *     background color is less than {@code 1.0f} and the window is decorated
3828      * @throws IllegalComponentStateException if the alpha value of the given
3829      *     background color is less than {@code 1.0f} and the window is in
3830      *     full-screen mode
3831      * @throws UnsupportedOperationException if the alpha value of the given
3832      *     background color is less than {@code 1.0f} and {@link
3833      *     GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT
3834      *     PERPIXEL_TRANSLUCENT} translucency is not supported
3835      *
3836      * @see Window#getBackground
3837      * @see Window#isOpaque
3838      * @see Window#setOpacity(float)
3839      * @see Window#setShape(Shape)
3840      * @see Frame#isUndecorated
3841      * @see Dialog#isUndecorated
3842      * @see GraphicsDevice.WindowTranslucency
3843      * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
3844      * @see GraphicsConfiguration#isTranslucencyCapable()
3845      */
3846     @Override
3847     @SuppressWarnings("deprecation")
3848     public void setBackground(Color bgColor) {
3849         Color oldBg = getBackground();
3850         super.setBackground(bgColor);
3851         if (oldBg != null && oldBg.equals(bgColor)) {
3852             return;
3853         }
3854         int oldAlpha = oldBg != null ? oldBg.getAlpha() : 255;
3855         int alpha = bgColor != null ? bgColor.getAlpha() : 255;
3856         if ((oldAlpha == 255) && (alpha < 255)) { // non-opaque window
3857             GraphicsConfiguration gc = getGraphicsConfiguration();
3858             GraphicsDevice gd = gc.getDevice();
3859             if (gc.getDevice().getFullScreenWindow() == this) {
3860                 throw new IllegalComponentStateException(
3861                     "Making full-screen window non opaque is not supported.");
3862             }
3863             if (!gc.isTranslucencyCapable()) {
3864                 GraphicsConfiguration capableGC = gd.getTranslucencyCapableGC();
3865                 if (capableGC == null) {
3866                     throw new UnsupportedOperationException(
3867                         "PERPIXEL_TRANSLUCENT translucency is not supported");


3880 
3881     /**
3882      * Indicates if the window is currently opaque.
3883      * <p>
3884      * The method returns {@code false} if the background color of the window
3885      * is not {@code null} and the alpha component of the color is less than
3886      * {@code 1.0f}. The method returns {@code true} otherwise.
3887      *
3888      * @return {@code true} if the window is opaque, {@code false} otherwise
3889      *
3890      * @see Window#getBackground
3891      * @see Window#setBackground(Color)
3892      * @since 1.7
3893      */
3894     @Override
3895     public boolean isOpaque() {
3896         Color bg = getBackground();
3897         return bg != null ? bg.getAlpha() == 255 : true;
3898     }
3899 
3900     @SuppressWarnings("deprecation")
3901     private void updateWindow() {
3902         synchronized (getTreeLock()) {
3903             WindowPeer peer = (WindowPeer)getPeer();
3904             if (peer != null) {
3905                 peer.updateWindow();
3906             }
3907         }
3908     }
3909 
3910     /**
3911      * {@inheritDoc}
3912      *
3913      * @since 1.7
3914      */
3915     @Override
3916     public void paint(Graphics g) {
3917         if (!isOpaque()) {
3918             Graphics gg = g.create();
3919             try {
3920                 if (gg instanceof Graphics2D) {


4071                     bg = new Color(0, 0, 0, 0);
4072                 }
4073                 window.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue(),
4074                                                opaque ? 255 : 0));
4075             }
4076             public void updateWindow(Window window) {
4077                 window.updateWindow();
4078             }
4079 
4080             public Dimension getSecurityWarningSize(Window window) {
4081                 return new Dimension(window.securityWarningWidth,
4082                         window.securityWarningHeight);
4083             }
4084 
4085             public void setSecurityWarningSize(Window window, int width, int height)
4086             {
4087                 window.securityWarningWidth = width;
4088                 window.securityWarningHeight = height;
4089             }
4090 
4091             @SuppressWarnings("deprecation")
4092             public void setSecurityWarningPosition(Window window,
4093                     Point2D point, float alignmentX, float alignmentY)
4094             {
4095                 window.securityWarningPointX = point.getX();
4096                 window.securityWarningPointY = point.getY();
4097                 window.securityWarningAlignmentX = alignmentX;
4098                 window.securityWarningAlignmentY = alignmentY;
4099 
4100                 synchronized (window.getTreeLock()) {
4101                     WindowPeer peer = (WindowPeer)window.getPeer();
4102                     if (peer != null) {
4103                         peer.repositionSecurityWarning();
4104                     }
4105                 }
4106             }
4107 
4108             public Point2D calculateSecurityWarningPosition(Window window,
4109                     double x, double y, double w, double h)
4110             {
4111                 return window.calculateSecurityWarningPosition(x, y, w, h);


< prev index next >