root / branches / v2_0_0_prep / extensions / org.gvsig.mkmvnproject / templates / 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 |
public void showWindow(JPanel panel, String title, int mode) { |
40 |
JFrame frame;
|
41 |
|
42 |
frame = new JFrame(); |
43 |
//frame.setAlwaysOnTop(true);
|
44 |
|
45 |
final Dimension s = Toolkit.getDefaultToolkit().getScreenSize(); |
46 |
frame.setLocation(s.width / 4, s.height / 4); |
47 |
|
48 |
frame.setLayout(new BorderLayout()); |
49 |
frame.setTitle(title); |
50 |
frame.add(panel, BorderLayout.CENTER);
|
51 |
|
52 |
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
53 |
|
54 |
frame.setSize(400,400); |
55 |
panel.addComponentListener(this);
|
56 |
|
57 |
frame.pack(); |
58 |
frame.setVisible(true);
|
59 |
} |
60 |
|
61 |
public void componentHidden(ComponentEvent arg0) { |
62 |
JFrame frame = (JFrame) ((JPanel) arg0.getSource()).getRootPane().getParent(); |
63 |
frame.setVisible(false);
|
64 |
frame.dispose(); |
65 |
} |
66 |
public void componentMoved(ComponentEvent arg0) { |
67 |
// Do nothing
|
68 |
|
69 |
} |
70 |
public void componentResized(ComponentEvent arg0) { |
71 |
// Do nothing
|
72 |
|
73 |
} |
74 |
public void componentShown(ComponentEvent arg0) { |
75 |
// Do nothing
|
76 |
|
77 |
} |
78 |
|
79 |
} |