Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.ui / src / test / java / org / gvsig / gui / beans / swing / textBoxWithCalendar / TestJCalendarDateDialog.java @ 40561

History | View | Annotate | Download (4.44 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.gui.beans.swing.textBoxWithCalendar;
25

    
26
import java.awt.Dimension;
27
import java.awt.event.MouseAdapter;
28
import java.awt.event.MouseEvent;
29
import java.io.Serializable;
30
import java.text.SimpleDateFormat;
31
import java.util.Locale;
32

    
33
import javax.swing.JButton;
34
import javax.swing.JFrame;
35

    
36
import org.gvsig.gui.beans.Messages;
37

    
38
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
39
 *
40
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
41
 *
42
 * This program is free software; you can redistribute it and/or
43
 * modify it under the terms of the GNU General Public License
44
 * as published by the Free Software Foundation; either version 2
45
 * of the License, or (at your option) any later version.
46
 *
47
 * This program is distributed in the hope that it will be useful,
48
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
49
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
50
 * GNU General Public License for more details.
51
 *
52
 * You should have received a copy of the GNU General Public License
53
 * along with this program; if not, write to the Free Software
54
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
55
 *
56
 * For more information, contact:
57
 *
58
 *  Generalitat Valenciana
59
 *   Conselleria d'Infraestructures i Transport
60
 *   Av. Blasco Ib??ez, 50
61
 *   46010 VALENCIA
62
 *   SPAIN
63
 *
64
 *      +34 963862235
65
 *   gvsig@gva.es
66
 *      www.gvsig.gva.es
67
 *
68
 *    or
69
 *
70
 *   IVER T.I. S.A
71
 *   Salamanca 50
72
 *   46005 Valencia
73
 *   Spain
74
 *
75
 *   +34 963163400
76
 *   dac@iver.es
77
 */
78

    
79
/**
80
 * Tests the JCalendarDateDialog  -> creates a JFrame that allows use a JCalendarDateDialog  object
81

82
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
83
 */
84
public class TestJCalendarDateDialog extends JFrame implements Serializable {
85
        private static final long serialVersionUID = 5885608277555264729L;
86
        private static JCalendarDateDialog t;
87

    
88
        /**
89
         * Test method for the TestJCalendarCDatePanel class
90
         * @param args
91
         */
92
        public static void main(String[] args)
93
        {
94
                int widthJF = 200;
95
                int heightJF = 50;
96
                int widthJB = 30;
97
                int heightJB = 20;
98
                
99
                // Objects creation
100
                JFrame jF = new JFrame();
101
                
102
                // JCalendarDateDialog
103
                t = new JCalendarDateDialog();                
104
                
105
                // Test Modal
106
                t.setModal(true);
107
                
108
                // Test set minimum dimension
109
//                t.setMinimumWidth(200);
110
//                t.setMinimumHeight(150);
111
                t.setMinimumWidthScreenResolutionPercentage(0.30);
112
                t.setMinimumHeightScreenResolutionPercentage(0.20);
113
                
114
                // Test set maximum dimension
115
//                t.setMaximumWidth(500);
116
//                t.setMaximumHeight(400);                
117
                t.setMaximumWidthScreenResolutionPercentage(0.60);
118
                t.setMaximumHeightScreenResolutionPercentage(0.40);                
119

    
120
                // Test Resize the component:
121
                t.setSizeResize(350, 300);
122
                
123
                // Creates a JButton
124
                JButton jButton = new JButton();
125
                jButton.setPreferredSize(new Dimension(widthJB, heightJB));
126
                jButton.setText(Messages.getText("date"));
127
                jButton.addMouseListener(new MouseAdapter() {
128
                        /*
129
                         *  (non-Javadoc)
130
                         * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
131
                         */
132
                        public void mouseClicked(MouseEvent e) {
133
                                t.setVisible(true);
134
                                t.setLocationRelativeTo(null);
135
                                System.out.println("Selected date: " + new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(t.getDate()));
136
                        }
137
                });
138
                
139
                // Set properties
140
                jF.setTitle("Test JCalendarDateDialog");
141
                jF.setSize(new Dimension(widthJF, heightJF));            
142
            jF.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
143
            jF.getContentPane().add(jButton);
144
            jF.setLocationRelativeTo(null);
145
                
146
                jF.setVisible(true);
147
        
148
        }
149
}