/* * Copyright (C) 2016 Didier Clermonté * Copyright (C) 2016 Christian Pierre Momon * * This file is part of Siba. * * Siba is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ package org.dclermonte.siba.gui; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Cursor; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.ResourceBundle; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextPane; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * * @author dclermonte * */ public class AboutDialog extends JDialog { private static final long serialVersionUID = 8868109575782482455L; private static ResourceBundle BUNDLE = ResourceBundle.getBundle("org.dclermonte.siba.gui.messages"); //$NON-NLS-1$ public static final Logger logger = LoggerFactory.getLogger(AboutDialog.class); /** * This is the constructor for the dialog. * * @throws IOException */ public AboutDialog() throws IOException { setMinimumSize(new Dimension(600, 350)); setMaximumSize(new Dimension(600, 500)); setIconImage(Toolkit.getDefaultToolkit() .getImage(AboutDialog.class.getResource("/org/dclermonte/siba/gui/SibaLogo.png"))); setBackground(Color.GREEN); getContentPane().setBackground(Color.GREEN); setBounds(100, 100, 450, 300); getContentPane().setLayout(new BorderLayout()); { JPanel buttonPane = new JPanel(); buttonPane.setBackground(Color.GREEN); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton okButton = new JButton("OK"); okButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { setVisible(false); dispose(); } }); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } } JPanel panel = new JPanel(); panel.setBackground(Color.GREEN); getContentPane().add(panel, BorderLayout.CENTER); panel.setLayout(new BorderLayout(0, 0)); JTextPane txtpnSimpleBackupDveloppeur = new JTextPane(); txtpnSimpleBackupDveloppeur.setBackground(Color.GREEN); txtpnSimpleBackupDveloppeur.setFont(new Font("Dialog", Font.BOLD, 14)); txtpnSimpleBackupDveloppeur.setContentType("text/html"); String path = System.getProperty("user.dir"); String about = BUNDLE.getString("AboutDialog"); File aboutFile = new File(path + "/src/org/dclermonte/siba/gui/" + about); FileReader in = new FileReader(aboutFile); BufferedReader bufferedReader = new BufferedReader(in); StringBuilder stringBuilder = new StringBuilder(); String lines; String line; while ((line = bufferedReader.readLine()) != null) { stringBuilder.append(line); } lines = stringBuilder.toString(); txtpnSimpleBackupDveloppeur.setText(lines); System.out.println("texte = " + lines); // "Simple Backup\n\nDéveloppeur Christian Pierre Momon et Didier // Clermonté\n\nLicence GNU Affero General Public License 2016"); panel.add(txtpnSimpleBackupDveloppeur); { JLabel lblNewLabel = new JLabel(""); lblNewLabel .setIcon(new ImageIcon(AboutDialog.class.getResource("/org/dclermonte/siba/gui/SibaLogo_256.png"))); panel.add(lblNewLabel, BorderLayout.WEST); } } /** * This method Launch the application. */ public static void main(final String string) { try { AboutDialog dialog = new AboutDialog(); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setVisible(true); } catch (Exception exception) { logger.error("Exception ", exception); } } }