1246 } |
1246 } |
1247 |
1247 |
1248 |
1248 |
1249 /** |
1249 /** |
1250 * Disables or enables decorations for this dialog. |
1250 * Disables or enables decorations for this dialog. |
1251 * This method can only be called while the dialog is not displayable. |
1251 * <p> |
1252 * @param undecorated <code>true</code> if no dialog decorations are |
1252 * This method can only be called while the dialog is not displayable. To |
1253 * to be enabled; |
1253 * make this dialog decorated, it must be opaque and have the default shape, |
1254 * <code>false</code> if dialog decorations are to be enabled. |
1254 * otherwise the {@code IllegalComponentStateException} will be thrown. |
1255 * @throws <code>IllegalComponentStateException</code> if the dialog |
1255 * Refer to {@link Window#setShape}, {@link Window#setOpacity} and {@link |
1256 * is displayable. |
1256 * Window#setBackground} for details |
|
1257 * |
|
1258 * @param undecorated {@code true} if no dialog decorations are to be |
|
1259 * enabled; {@code false} if dialog decorations are to be enabled |
|
1260 * |
|
1261 * @throws IllegalComponentStateException if the dialog is displayable |
|
1262 * @throws IllegalComponentStateException if {@code undecorated} is |
|
1263 * {@code false}, and this dialog does not have the default shape |
|
1264 * @throws IllegalComponentStateException if {@code undecorated} is |
|
1265 * {@code false}, and this dialog opacity is less than {@code 1.0f} |
|
1266 * @throws IllegalComponentStateException if {@code undecorated} is |
|
1267 * {@code false}, and the alpha value of this dialog background |
|
1268 * color is less than {@code 1.0f} |
|
1269 * |
1257 * @see #isUndecorated |
1270 * @see #isUndecorated |
1258 * @see Component#isDisplayable |
1271 * @see Component#isDisplayable |
|
1272 * @see Window#getShape |
|
1273 * @see Window#getOpacity |
|
1274 * @see Window#getBackground |
|
1275 * |
1259 * @since 1.4 |
1276 * @since 1.4 |
1260 */ |
1277 */ |
1261 public void setUndecorated(boolean undecorated) { |
1278 public void setUndecorated(boolean undecorated) { |
1262 /* Make sure we don't run in the middle of peer creation.*/ |
1279 /* Make sure we don't run in the middle of peer creation.*/ |
1263 synchronized (getTreeLock()) { |
1280 synchronized (getTreeLock()) { |
1264 if (isDisplayable()) { |
1281 if (isDisplayable()) { |
1265 throw new IllegalComponentStateException("The dialog is displayable."); |
1282 throw new IllegalComponentStateException("The dialog is displayable."); |
|
1283 } |
|
1284 if (!undecorated) { |
|
1285 if (getOpacity() < 1.0f) { |
|
1286 throw new IllegalComponentStateException("The dialog is not opaque"); |
|
1287 } |
|
1288 if (getShape() != null) { |
|
1289 throw new IllegalComponentStateException("The dialog does not have a default shape"); |
|
1290 } |
|
1291 Color bg = getBackground(); |
|
1292 if ((bg != null) && (bg.getAlpha() < 255)) { |
|
1293 throw new IllegalComponentStateException("The dialog background color is not opaque"); |
|
1294 } |
1266 } |
1295 } |
1267 this.undecorated = undecorated; |
1296 this.undecorated = undecorated; |
1268 } |
1297 } |
1269 } |
1298 } |
1270 |
1299 |
1276 * @see java.awt.Dialog#setUndecorated |
1305 * @see java.awt.Dialog#setUndecorated |
1277 * @since 1.4 |
1306 * @since 1.4 |
1278 */ |
1307 */ |
1279 public boolean isUndecorated() { |
1308 public boolean isUndecorated() { |
1280 return undecorated; |
1309 return undecorated; |
|
1310 } |
|
1311 |
|
1312 /** |
|
1313 * {@inheritDoc} |
|
1314 */ |
|
1315 @Override |
|
1316 public void setOpacity(float opacity) { |
|
1317 synchronized (getTreeLock()) { |
|
1318 if ((opacity < 1.0f) && !isUndecorated()) { |
|
1319 throw new IllegalComponentStateException("The dialog is decorated"); |
|
1320 } |
|
1321 super.setOpacity(opacity); |
|
1322 } |
|
1323 } |
|
1324 |
|
1325 /** |
|
1326 * {@inheritDoc} |
|
1327 */ |
|
1328 @Override |
|
1329 public void setShape(Shape shape) { |
|
1330 synchronized (getTreeLock()) { |
|
1331 if ((shape != null) && !isUndecorated()) { |
|
1332 throw new IllegalComponentStateException("The dialog is decorated"); |
|
1333 } |
|
1334 super.setShape(shape); |
|
1335 } |
|
1336 } |
|
1337 |
|
1338 /** |
|
1339 * {@inheritDoc} |
|
1340 */ |
|
1341 @Override |
|
1342 public void setBackground(Color bgColor) { |
|
1343 synchronized (getTreeLock()) { |
|
1344 if ((bgColor != null) && (bgColor.getAlpha() < 255) && !isUndecorated()) { |
|
1345 throw new IllegalComponentStateException("The dialog is decorated"); |
|
1346 } |
|
1347 super.setBackground(bgColor); |
|
1348 } |
1281 } |
1349 } |
1282 |
1350 |
1283 /** |
1351 /** |
1284 * Returns a string representing the state of this dialog. This |
1352 * Returns a string representing the state of this dialog. This |
1285 * method is intended to be used only for debugging purposes, and the |
1353 * method is intended to be used only for debugging purposes, and the |