1 /*
2 * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
732
733 /**
734 * Construct a name for this component. Called by getName() when the
735 * name is null.
736 */
737 String constructComponentName() {
738 synchronized (Dialog.class) {
739 return base + nameCounter++;
740 }
741 }
742
743 /**
744 * Makes this Dialog displayable by connecting it to
745 * a native screen resource. Making a dialog displayable will
746 * cause any of its children to be made displayable.
747 * This method is called internally by the toolkit and should
748 * not be called directly by programs.
749 * @see Component#isDisplayable
750 * @see #removeNotify
751 */
752 public void addNotify() {
753 synchronized (getTreeLock()) {
754 if (parent != null && parent.getPeer() == null) {
755 parent.addNotify();
756 }
757
758 if (peer == null) {
759 peer = getToolkit().createDialog(this);
760 }
761 super.addNotify();
762 }
763 }
764
765 /**
766 * Indicates whether the dialog is modal.
767 * <p>
768 * This method is obsolete and is kept for backwards compatibility only.
769 * Use {@link #getModalityType getModalityType()} instead.
770 *
771 * @return <code>true</code> if this dialog window is modal;
880 * @param title the title displayed in the dialog's border;
881 * a null value results in an empty title
882 * @see #getTitle
883 */
884 public void setTitle(String title) {
885 String oldTitle = this.title;
886
887 synchronized(this) {
888 this.title = title;
889 DialogPeer peer = (DialogPeer)this.peer;
890 if (peer != null) {
891 peer.setTitle(title);
892 }
893 }
894 firePropertyChange("title", oldTitle, title);
895 }
896
897 /**
898 * @return true if we actually showed, false if we just called toFront()
899 */
900 private boolean conditionalShow(Component toFocus, AtomicLong time) {
901 boolean retval;
902
903 closeSplashScreen();
904
905 synchronized (getTreeLock()) {
906 if (peer == null) {
907 addNotify();
908 }
909 validateUnconditionally();
910 if (visible) {
911 toFront();
912 retval = false;
913 } else {
914 visible = retval = true;
915
916 // check if this dialog should be modal blocked BEFORE calling peer.show(),
917 // otherwise, a pair of FOCUS_GAINED and FOCUS_LOST may be mistakenly
918 // generated for the dialog
919 if (!isModal()) {
|
1 /*
2 * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
732
733 /**
734 * Construct a name for this component. Called by getName() when the
735 * name is null.
736 */
737 String constructComponentName() {
738 synchronized (Dialog.class) {
739 return base + nameCounter++;
740 }
741 }
742
743 /**
744 * Makes this Dialog displayable by connecting it to
745 * a native screen resource. Making a dialog displayable will
746 * cause any of its children to be made displayable.
747 * This method is called internally by the toolkit and should
748 * not be called directly by programs.
749 * @see Component#isDisplayable
750 * @see #removeNotify
751 */
752 @SuppressWarnings("deprecation")
753 public void addNotify() {
754 synchronized (getTreeLock()) {
755 if (parent != null && parent.getPeer() == null) {
756 parent.addNotify();
757 }
758
759 if (peer == null) {
760 peer = getToolkit().createDialog(this);
761 }
762 super.addNotify();
763 }
764 }
765
766 /**
767 * Indicates whether the dialog is modal.
768 * <p>
769 * This method is obsolete and is kept for backwards compatibility only.
770 * Use {@link #getModalityType getModalityType()} instead.
771 *
772 * @return <code>true</code> if this dialog window is modal;
881 * @param title the title displayed in the dialog's border;
882 * a null value results in an empty title
883 * @see #getTitle
884 */
885 public void setTitle(String title) {
886 String oldTitle = this.title;
887
888 synchronized(this) {
889 this.title = title;
890 DialogPeer peer = (DialogPeer)this.peer;
891 if (peer != null) {
892 peer.setTitle(title);
893 }
894 }
895 firePropertyChange("title", oldTitle, title);
896 }
897
898 /**
899 * @return true if we actually showed, false if we just called toFront()
900 */
901 @SuppressWarnings("deprecation")
902 private boolean conditionalShow(Component toFocus, AtomicLong time) {
903 boolean retval;
904
905 closeSplashScreen();
906
907 synchronized (getTreeLock()) {
908 if (peer == null) {
909 addNotify();
910 }
911 validateUnconditionally();
912 if (visible) {
913 toFront();
914 retval = false;
915 } else {
916 visible = retval = true;
917
918 // check if this dialog should be modal blocked BEFORE calling peer.show(),
919 // otherwise, a pair of FOCUS_GAINED and FOCUS_LOST may be mistakenly
920 // generated for the dialog
921 if (!isModal()) {
|