Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / org.gvsig.mkmvnproject / templates / SPI+UIAPI / org.gvsig.fortunecookies / org.gvsig.fortunecookies.swing / org.gvsig.fortunecookies.swing.impl / src / main / java / org / gvsig / fortunecookies / swing / impl / DefaultFortuneCookieWindowManager.java @ 32378

History | View | Annotate | Download (2.25 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

    
23
package org.gvsig.fortunecookies.swing.impl;
24

    
25
import java.awt.BorderLayout;
26
import java.awt.Dimension;
27
import java.awt.Toolkit;
28
import java.awt.event.ComponentEvent;
29
import java.awt.event.ComponentListener;
30

    
31
import javax.swing.JFrame;
32
import javax.swing.JPanel;
33

    
34
import org.gvsig.fortunecookies.swing.FortuneCookieWindowManager;
35

    
36

    
37
public class DefaultFortuneCookieWindowManager implements FortuneCookieWindowManager, ComponentListener{
38
        
39

    
40
        public void showWindow(JPanel panel, String title, int mode) {
41
                JFrame frame;
42
                
43
                frame = new JFrame();
44
                //frame.setAlwaysOnTop(true);
45
                
46
                final Dimension s = Toolkit.getDefaultToolkit().getScreenSize();
47
                frame.setLocation(s.width / 4, s.height / 4);
48
                
49
                frame.setLayout(new BorderLayout());
50
                frame.setTitle(title);
51
                frame.add(panel, BorderLayout.CENTER);
52
                
53
                frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
54

    
55
                frame.setSize(400,400);
56
                panel.addComponentListener(this);
57
                
58
                frame.pack();
59
                frame.setVisible(true);
60
        }
61
                        
62
        public void componentHidden(ComponentEvent arg0) {
63
                JFrame frame = (JFrame) ((JPanel) arg0.getSource()).getRootPane().getParent();
64
                frame.setVisible(false);
65
                frame.dispose();
66
        }
67
        public void componentMoved(ComponentEvent arg0) {
68
                // Do nothing
69
                
70
        }
71
        public void componentResized(ComponentEvent arg0) {
72
                // Do nothing
73
                
74
        }
75
        public void componentShown(ComponentEvent arg0) {
76
                // Do nothing
77
                
78
        }
79

    
80
}