Revision 7959
trunk/libraries/libUI/src-test/org/gvsig/gui/beans/textBoxWithCalendar/TestJCalendarDateDialog.java | ||
---|---|---|
1 |
package org.gvsig.gui.beans.textBoxWithCalendar; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.awt.Dimension; |
|
5 |
import java.awt.event.MouseAdapter; |
|
6 |
import java.awt.event.MouseEvent; |
|
7 |
import java.awt.event.MouseListener; |
|
8 |
import java.text.SimpleDateFormat; |
|
9 |
import java.util.Locale; |
|
10 |
|
|
11 |
import javax.swing.JButton; |
|
12 |
import javax.swing.JFrame; |
|
13 |
|
|
14 |
import org.gvsig.gui.beans.Messages; |
|
15 |
|
|
16 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
17 |
* |
|
18 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
19 |
* |
|
20 |
* This program is free software; you can redistribute it and/or |
|
21 |
* modify it under the terms of the GNU General Public License |
|
22 |
* as published by the Free Software Foundation; either version 2 |
|
23 |
* of the License, or (at your option) any later version. |
|
24 |
* |
|
25 |
* This program is distributed in the hope that it will be useful, |
|
26 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
27 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
28 |
* GNU General Public License for more details. |
|
29 |
* |
|
30 |
* You should have received a copy of the GNU General Public License |
|
31 |
* along with this program; if not, write to the Free Software |
|
32 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
33 |
* |
|
34 |
* For more information, contact: |
|
35 |
* |
|
36 |
* Generalitat Valenciana |
|
37 |
* Conselleria d'Infraestructures i Transport |
|
38 |
* Av. Blasco Ib??ez, 50 |
|
39 |
* 46010 VALENCIA |
|
40 |
* SPAIN |
|
41 |
* |
|
42 |
* +34 963862235 |
|
43 |
* gvsig@gva.es |
|
44 |
* www.gvsig.gva.es |
|
45 |
* |
|
46 |
* or |
|
47 |
* |
|
48 |
* IVER T.I. S.A |
|
49 |
* Salamanca 50 |
|
50 |
* 46005 Valencia |
|
51 |
* Spain |
|
52 |
* |
|
53 |
* +34 963163400 |
|
54 |
* dac@iver.es |
|
55 |
*/ |
|
56 |
|
|
57 |
/** |
|
58 |
* Tests the JCalendarDateDialog -> creates a JFrame that allows use a JCalendarDateDialog object |
|
59 |
|
|
60 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com) |
|
61 |
*/ |
|
62 |
public class TestJCalendarDateDialog extends JFrame{ |
|
63 |
private static JCalendarDateDialog t; |
|
64 |
|
|
65 |
/** |
|
66 |
* Test method for the TestJCalendarCDatePanel class |
|
67 |
* @param args |
|
68 |
*/ |
|
69 |
public static void main(String[] args) |
|
70 |
{ |
|
71 |
int widthJF = 200; |
|
72 |
int heightJF = 50; |
|
73 |
int widthJB = 30; |
|
74 |
int heightJB = 20; |
|
75 |
|
|
76 |
// Objects creation |
|
77 |
JFrame jF = new JFrame(); |
|
78 |
|
|
79 |
// JCalendarDateDialog |
|
80 |
t = new JCalendarDateDialog(); |
|
81 |
// Test Modal |
|
82 |
t.setModal(true); |
|
83 |
// Test Resize the component: |
|
84 |
t.setSizeResize(350, 300); |
|
85 |
|
|
86 |
// Creates a JButton |
|
87 |
JButton jButton = new JButton(); |
|
88 |
jButton.setPreferredSize(new Dimension(widthJB, heightJB)); |
|
89 |
jButton.setText(Messages.getText("date")); |
|
90 |
jButton.addMouseListener(new MouseAdapter() { |
|
91 |
/* |
|
92 |
* (non-Javadoc) |
|
93 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) |
|
94 |
*/ |
|
95 |
public void mouseClicked(MouseEvent e) { |
|
96 |
t.setVisible(true); |
|
97 |
t.setLocationRelativeTo(null); |
|
98 |
System.out.println("Selected date: " + new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(t.getDate())); |
|
99 |
} |
|
100 |
}); |
|
101 |
|
|
102 |
// Set properties |
|
103 |
jF.setTitle("Test JCalendarDateDialog"); |
|
104 |
jF.setSize(new Dimension(widthJF, heightJF)); |
|
105 |
jF.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
106 |
jF.getContentPane().add(jButton); |
|
107 |
jF.setLocationRelativeTo(null); |
|
108 |
|
|
109 |
jF.setVisible(true); |
|
110 |
|
|
111 |
} |
|
112 |
} |
Also available in: Unified diff