001: /*=============================================================================
002: * Copyright Texas Instruments 2001. All Rights Reserved.
003: *
004: * This program is free software; you can redistribute it and/or modify
005: * it under the terms of the GNU General Public License as published by
006: * the Free Software Foundation; either version 2 of the License, or
007: * (at your option) any later version.
008: *
009: * This program is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU General Public License for more details.
013: *
014: * You should have received a copy of the GNU General Public License
015: * along with this program; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */
018:
019: package javax.swing;
020:
021: import java.awt.*;
022:
023: import java.awt.event.*;
024:
025: import java.beans.PropertyVetoException;
026: import java.beans.PropertyChangeEvent;
027: import java.util.EventListener;
028:
029: import javax.swing.border.Border;
030: import javax.swing.event.InternalFrameEvent;
031: import javax.swing.event.InternalFrameListener;
032: import javax.swing.plaf.*;
033:
034: /**
035: * XXX hack to work around lack of publically accessible way to have a
036: * modal JInternalFrame...
037: *
038: * @author Rob Clark
039: * @version 0.1
040: */
041: public class JInternalFrameWrapper extends JInternalFrame {
042: /*=======================================================================*/
043: /**
044: *
045: *
046: */
047: public JInternalFrameWrapper(final String title, boolean resizable,
048: boolean closable, boolean maximizable, boolean iconifiable) {
049: super (title, resizable, closable, maximizable, iconifiable);
050:
051: /* Hack workaround for JDK v1.3.x DnD bug:
052: */
053: if (System.getProperty("java.version").startsWith("1.3")) {
054: class HackGlassPane extends JPanel {
055: HackGlassPane() {
056: super ();
057: super .setName(title + ".glassPane");
058: super .setVisible(false);
059: super .setOpaque(false);
060: }
061:
062: public void setVisible(boolean b) { /* no-op */
063: }
064:
065: public Component findComponentAt(int x, int y) {
066: return null;
067: }
068: }
069:
070: setGlassPane(new HackGlassPane());
071: }
072: }
073:
074: public void showModal() {
075: throw new ti.exceptions.ProgrammingErrorException(
076: "I don't think this should be called anymore!");
077: // startModal();
078:
079: // XXX not quite ideal, but calling startModal triggers an IllegalAccessError...
080:
081: /* Since all input will be blocked until this dialog is dismissed,
082: * make sure its parent containers are visible first (this component
083: * is tested below). This is necessary for JApplets, because
084: * because an applet normally isn't made visible until after its
085: * start() method returns -- if this method is called from start(),
086: * the applet will appear to hang while an invisible modal frame
087: * waits for input.
088: */
089: /* if (isVisible() && !isShowing()) {
090: Container parent = this.getParent();
091: while (parent != null) {
092: if (parent.isVisible() == false) {
093: parent.setVisible(true);
094: }
095: parent = parent.getParent();
096: }
097: }
098:
099: try {
100: if (SwingUtilities.isEventDispatchThread()) {
101: EventQueue theQueue = getToolkit().getSystemEventQueue();
102: while (isVisible()) {
103: // This is essentially the body of EventDispatchThread
104: AWTEvent event = theQueue.getNextEvent();
105: Object src = event.getSource();
106: // can't call theQueue.dispatchEvent, so I pasted its body here
107: if (event instanceof ActiveEvent) {
108: ((ActiveEvent) event).dispatch();
109: } else if (src instanceof Component) {
110: ((Component) src).dispatchEvent(event);
111: } else if (src instanceof MenuComponent) {
112: ((MenuComponent) src).dispatchEvent(event);
113: } else {
114: System.err.println("unable to dispatch event: " + event);
115: }
116: }
117: } else
118: while (isVisible())
119: try {
120: Thread.sleep(300);
121: } catch(InterruptedException e) {
122: break;
123: }
124: } catch(InterruptedException e){}
125: */
126: }
127: }
128:
129: /*
130: * Local Variables:
131: * tab-width: 2
132: * indent-tabs-mode: nil
133: * mode: java
134: * c-indentation-style: java
135: * eval: (c-set-offset 'substatement-open '0)
136: * c-basic-offset: 2
137: * End:
138: */
|