Java Tutorial/Swing/Window — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 15:33, 31 мая 2010
Get all windows from Window.getWindows()
import java.awt.Frame;
import java.awt.Window;
import javax.swing.JDialog;
import javax.swing.JFrame;
public class MainClass {
public static void main(String[] args) {
JDialog d1 = new JDialog((JFrame) null, "Dialog 1");
d1.setName("Dialog 1");
JDialog d2 = new JDialog((Window) null, "Dialog 2");
d2.setName("Dialog 2");
Frame f = new Frame();
f.setName("Frame 1");
Window w1 = new Window(f);
w1.setName("Window 1");
Window w2 = new Window(null);
w2.setName("Window 2");
Window[] windows = Window.getWindows();
for (Window window : windows)
System.out.println(window.getName() + ": " + window.getClass());
}
}
Window.getOwnerlessWindows ()
import java.awt.Frame;
import java.awt.Window;
import javax.swing.JDialog;
import javax.swing.JFrame;
public class MainClass {
public static void main(String[] args) {
JDialog d1 = new JDialog((JFrame) null, "Dialog 1");
d1.setName("Dialog 1");
JDialog d2 = new JDialog((Window) null, "Dialog 2");
d2.setName("Dialog 2");
Frame f = new Frame();
f.setName("Frame 1");
Window w1 = new Window(f);
w1.setName("Window 1");
Window w2 = new Window(null);
w2.setName("Window 2");
Window [] ownerlessWindows = Window.getOwnerlessWindows ();
for (Window window: ownerlessWindows)
System.out.println (window.getName ()+": "+window.getClass ());
}
}