/**
*
*/
package de.tutorials;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.Timer;
/**
* @author Tom
*
*/
public class JInternalFrameGetBoundsExample extends JFrame {
public JInternalFrameGetBoundsExample() {
super("JInternalFrameGetBoundsExample");
setDefaultCloseOperation(EXIT_ON_CLOSE);
final JDesktopPane desktopPane = new JDesktopPane();
desktopPane.setPreferredSize(new Dimension(640, 480));
JInternalFrame internalFrame = new JInternalFrame("tutorials.de", true,
true, true, true);
internalFrame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
internalFrame.setSize(160, 120);
internalFrame.setVisible(true);
desktopPane.add(internalFrame);
internalFrame = new JInternalFrame("google.de", true, true, true, true);
internalFrame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
internalFrame.setSize(320, 240);
internalFrame.setVisible(true);
desktopPane.add(internalFrame);
add(desktopPane);
pack();
setVisible(true);
Timer timer = new Timer(1000, new ActionListener() {
public void actionPerformed(ActionEvent e) {
JInternalFrame[] internalFrames = desktopPane.getAllFrames();
for (int i = 0; i < internalFrames.length; i++) {
JInternalFrame frame = internalFrames[i];
System.out.println(frame.getTitle() + " -> "
+ frame.getBounds());
}
}
});
timer.setRepeats(true);
timer.start();
}
/**
* @param args
*/
public static void main(String[] args) {
new JInternalFrameGetBoundsExample();
}
}