Browse Source

Frames are now staggered as they're opened, so you don't end up with too many windows in the same place

git-svn-id: http://svn.dmdirc.com/trunk@201 00569f92-eb28-0410-84fd-f71c24880f
tags/0.1
Chris Smith 17 years ago
parent
commit
7f0d140c57
1 changed files with 26 additions and 2 deletions
  1. 26
    2
      src/uk/org/ownage/dmdirc/ui/MainFrame.java

+ 26
- 2
src/uk/org/ownage/dmdirc/ui/MainFrame.java View File

@@ -45,6 +45,9 @@ public class MainFrame extends javax.swing.JFrame {
45 45
      */
46 46
     private boolean maximised;
47 47
     
48
+    private int xOffset = 0;
49
+    private int yOffset = 0;
50
+    
48 51
     /**
49 52
      * Returns the singleton instance of MainFrame
50 53
      * @return MainFrame instance
@@ -86,12 +89,33 @@ public class MainFrame extends javax.swing.JFrame {
86 89
      * @param frame the frame to be added
87 90
      */
88 91
     public void addChild(JInternalFrame frame) {
92
+        // Add the frame
89 93
         desktopPane.add(frame);
94
+        
95
+        // Make sure it'll fit with our offsets
96
+        if (frame.getWidth()+xOffset > desktopPane.getWidth()) {
97
+            xOffset = 0;
98
+            System.out.println("Resetting xOffset");
99
+        }
100
+        if (frame.getHeight()+yOffset > desktopPane.getHeight()) {
101
+            yOffset = 0;
102
+            System.out.println("Resetting yOffset");
103
+        }
104
+        
105
+        System.out.println("x = "+xOffset+" y = "+yOffset);
106
+        
107
+        // Position the frame
108
+        frame.setLocation(xOffset, yOffset);
109
+        frame.moveToFront();
110
+        
111
+        // Increase the offsets
112
+        xOffset += 30;
113
+        yOffset += 30;
90 114
     }
91 115
     
92 116
     public void delChild(JInternalFrame frame) {
93 117
         desktopPane.remove(frame);
94
-    }    
118
+    }
95 119
     
96 120
     /**
97 121
      * Returns the JInternalFrame that is currently active
@@ -175,7 +199,7 @@ public class MainFrame extends javax.swing.JFrame {
175 199
         );
176 200
         pack();
177 201
     }// </editor-fold>//GEN-END:initComponents
178
-
202
+    
179 203
     
180 204
     // Variables declaration - do not modify//GEN-BEGIN:variables
181 205
     private javax.swing.JDesktopPane desktopPane;

Loading…
Cancel
Save