01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Pavel Dolgov
19: * @version $Revision$
20: */package java.awt;
21:
22: /**
23: *
24: * The context for nested event loop. It can be dialog, popup menu etc.
25: */
26: class ModalContext {
27:
28: private boolean running = false;
29:
30: private final Toolkit toolkit;
31:
32: ModalContext() {
33: toolkit = Toolkit.getDefaultToolkit();
34: }
35:
36: /**
37: * Set up and run modal loop in this context
38: *
39: */
40: void runModalLoop() {
41: if (!running) {
42: running = true;
43: toolkit.dispatchThread.runModalLoop(this );
44: }
45: }
46:
47: /**
48: * Leave the modal loop running in this context
49: * This method doesn't stops the loop immediately,
50: * it just sets the flag that says the modal loop to stop
51: *
52: */
53: void endModalLoop() {
54: running = false;
55: }
56:
57: /**
58: *
59: * @return modal loop is currently running in this context
60: */
61: boolean isModalLoopRunning() {
62: return running;
63: }
64:
65: }
|