ERLEDIGT
NEIN
NEIN
ANTWORTEN
2
2
ZUGRIFFE
318
318
EMPFEHLEN
-
06.03.06 12:07 #1
- Registriert seit
- Nov 2005
- Beiträge
- 76
Hallo,
kennt jemand ein einfaches Beispiel, bei der ich die Position (getX() + getY() ) eines JInternalFrames im Hauptframe bestimmen kann?
Ich glaube das funktioniert mit dem MouseListener.
Danke,
Andreas.
-
06.03.06 20:18 #2
- Registriert seit
- Jun 2002
- Ort
- Saarbrücken (Saarland)
- Beiträge
- 9.886
- Blog-Einträge
- 29
Hallo!
Schau mal hier:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
/** * */ 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(); } }
Gruß TomJava rocks!
How to become a good Java Programmer?
Does IT in Java and .Net
The only valid measurement of code quality: WTFs / minute
Blog
Xing
Twitter
-
07.03.06 08:27 #3
- Registriert seit
- Nov 2005
- Beiträge
- 76
Vielen Dank, Tom.





Zitieren

Login





