2 * Sudokuki - essential sudoku game
3 * Copyright (C) 2007-2016 Sylvain Vedrenne
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.jankenpoi.sudokuki.ui.swing;
20 import static net.jankenpoi.i18n.I18n.gtxt;
22 import java.awt.Color;
23 import java.awt.Desktop;
24 import java.awt.Dimension;
25 import java.awt.Frame;
26 import java.awt.event.ActionEvent;
27 import java.awt.event.ActionListener;
28 import java.io.IOException;
30 import java.net.URISyntaxException;
32 import javax.swing.BoxLayout;
33 import javax.swing.JButton;
34 import javax.swing.JDialog;
35 import javax.swing.JLabel;
36 import javax.swing.JPanel;
37 import javax.swing.SwingConstants;
39 @SuppressWarnings("serial")
40 public class TranslateDialog extends JDialog {
44 public TranslateDialog(Frame parent) {
48 // setResizable(false);
49 setTitle(gtxt("Translate this application"));
53 private void initComponents() {
54 URI sudokukiURI = null;
56 sudokukiURI = new URI("http://sourceforge.net/projects/sudokuki/forums/forum/1801058");
57 } catch (URISyntaxException e1) {
61 JPanel panel = makeInfoPanel(sudokukiURI);
65 Dimension parentDim = parent.getPreferredSize();
66 Dimension dim = new Dimension();
67 dim.setSize(parentDim.getHeight() * 1.75, parentDim.getWidth() * 1.25);
70 setLocationRelativeTo(parent);
73 protected JPanel makeInfoPanel(final URI sudokukiURI) {
74 JPanel panel = new JPanel(false);
75 panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
77 JPanel feedbackPanel = new JPanel(false);
78 String feedbackStr = "<html>"
79 + "<table border=\"0\">"
83 + gtxt("You can easily translate Sudokuki into your own language!")+"<br/>"
87 + gtxt("Propose your help and get information on how to proceed<br/> on the Translators Forum hosted by Sourceforge:")+"<br/>"
90 + "</tr>" + "<tr>" + "</tr>" + "</table>" + "</html>";
91 JLabel label = new JLabel(feedbackStr);
92 feedbackPanel.add(label);
94 panel.add(feedbackPanel);
96 JPanel linkPanel = new JPanel(false);
97 JButton linkButton = new JButton();
100 .setText("<HTML><FONT color=\"#000099\"><U>"+gtxt("Sudokuki Translators Forum")+"</U></FONT></HTML>");
101 linkButton.setHorizontalAlignment(SwingConstants.CENTER);
102 linkButton.setBorderPainted(false);
103 linkButton.setOpaque(false);
104 linkButton.setBackground(Color.WHITE);
105 linkButton.setToolTipText(sudokukiURI.toString());
106 linkButton.addActionListener(new ActionListener() {
108 public void actionPerformed(ActionEvent e) {
109 TranslateDialog.this.open(sudokukiURI);
112 linkButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
113 linkPanel.add(linkButton);
114 panel.add(linkPanel);
119 private void open(URI uri) {
120 if (Desktop.isDesktopSupported()) {
121 Desktop desktop = Desktop.getDesktop();
124 } catch (IOException e) {
128 // TODO: error handling