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 / DefaultJFortuneCookieServiceInfoPanel.java @ 32378
History | View | Annotate | Download (2.85 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.event.ActionEvent; |
28 |
import java.awt.event.ActionListener; |
29 |
|
30 |
import javax.swing.BorderFactory; |
31 |
import javax.swing.Box; |
32 |
import javax.swing.BoxLayout; |
33 |
import javax.swing.JButton; |
34 |
import javax.swing.JPanel; |
35 |
import javax.swing.JScrollPane; |
36 |
import javax.swing.JTextArea; |
37 |
|
38 |
import org.gvsig.fortunecookies.FortuneCookieService; |
39 |
import org.gvsig.fortunecookies.exception.FortuneCookieMessageException; |
40 |
import org.gvsig.fortunecookies.swing.FortuneCookieUIManager; |
41 |
|
42 |
|
43 |
public class DefaultJFortuneCookieServiceInfoPanel extends JPanel{ |
44 |
|
45 |
/**
|
46 |
*
|
47 |
*/
|
48 |
private static final long serialVersionUID = 2965442763236823977L; |
49 |
protected JButton accept = null; |
50 |
|
51 |
|
52 |
public DefaultJFortuneCookieServiceInfoPanel(FortuneCookieUIManager uimanager, FortuneCookieService cookie) {
|
53 |
|
54 |
this.setLayout(new BorderLayout()); |
55 |
this.setPreferredSize(new Dimension(550,150)); |
56 |
|
57 |
JTextArea text = new JTextArea(); |
58 |
try {
|
59 |
text.setText("Message: " +cookie.getMessage()+"\nDate: " + cookie.getDate()); |
60 |
} catch (FortuneCookieMessageException e) {
|
61 |
text.setText(uimanager.getTranslation("Error obtaining message....."));
|
62 |
e.printStackTrace(); |
63 |
} |
64 |
text.setEditable(false);
|
65 |
|
66 |
JScrollPane scrollPane = new JScrollPane(text); |
67 |
scrollPane.setPreferredSize(new Dimension(550, 150)); |
68 |
|
69 |
accept = new JButton(uimanager.getTranslation("Accept")); |
70 |
|
71 |
JPanel optionsPane = new JPanel(); |
72 |
optionsPane.setLayout(new BoxLayout(optionsPane, BoxLayout.LINE_AXIS)); |
73 |
optionsPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
74 |
optionsPane.add(Box.createHorizontalGlue());
|
75 |
|
76 |
accept.addActionListener(new ActionListener(){ |
77 |
public void actionPerformed(ActionEvent arg0) { |
78 |
setVisible(false);
|
79 |
} |
80 |
}); |
81 |
optionsPane.add(accept); |
82 |
optionsPane.add(Box.createRigidArea(new Dimension(10, 0))); |
83 |
|
84 |
this.add(scrollPane, BorderLayout.CENTER); |
85 |
this.add(optionsPane, BorderLayout.SOUTH); |
86 |
|
87 |
|
88 |
} |
89 |
|
90 |
} |