package beaform.gui;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.UIManager;
import javax.swing.WindowConstants;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * This class implements an about dialog.
 *
 * @author steven
 *
 */
public class About implements Runnable {
	private static final Logger LOG = LoggerFactory.getLogger(About.class);
	private static JFrame frm = new JFrame("About...");
	private static JPanel pane = new JPanel();
	private static JLabel lblTitle = new JLabel();
	private static JLabel lblAuthor = new JLabel();
	private static JTextArea txtLicense = new JTextArea();

	@Override
	public void run() {
		createAndShowGUI();
	}

	private void init(){

		//Create pane and add components
		pane.setLayout(new GridBagLayout()); //create pane
		final GridBagConstraints cconstraints = new GridBagConstraints();
		//c.fill = GridBagConstraints.HORIZONTAL;
		cconstraints.weightx = 0.5;

		cconstraints.gridx = 0;
		cconstraints.gridy = 0;
		lblTitle.setText("BeaForm");
		pane.add(lblTitle, cconstraints);

		cconstraints.gridx = 0;
		cconstraints.gridy = 1;
		lblAuthor.setText("By Steven Post");
		pane.add(lblAuthor, cconstraints);

		cconstraints.gridx = 0;
		cconstraints.gridy = 2;
		txtLicense.setText("This program is distributed under the MIT License.\n You can re-distribute, and/or modify the program under the conditions of the MIT License.");
		txtLicense.setEditable(false);
		pane.add(txtLicense, cconstraints);

		pane.setBorder(BorderFactory.createEmptyBorder(20, /*top*/20, /*left*/20, /*bottom*/20)/*right*/);

	}

	public static void createAndShowGUI() {
		//Set the look and feel.
		try{
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		}
		catch (Exception e){
			if (LOG.isErrorEnabled()) {
				LOG.error("Look'n feel: " + e.getMessage());
			}
		}

		//Make sure we have nice window decorations.
		JFrame.setDefaultLookAndFeelDecorated(true);

		//Create and set up the window.
		//JFrame frame = new JFrame("GUI testing");
		frm.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

		final About app = new About();
		app.init();
		final Component contents = pane;
		frm.getContentPane().add(contents, BorderLayout.CENTER);
		frm.setLocation(150, 150);

		//Display the window.
		frm.setMinimumSize(new Dimension(200, 100));
		frm.pack();
		//frame.setResizable(false);
		frm.setVisible(true);
		//frame.setSize(235, 165);
	}
}

@@ -352,24 +352,77 @@
 UIManager;%0D%0A
+import javax.swing.UnsupportedLookAndFeelException;%0D%0A
 import javax
@@ -446,16 +446,16 @@
 tants;%0D%0A
-
 %0D%0Aimport
@@ -630,16 +630,34 @@
 nable %7B%0D
+%0A%0D%0A%09/** Logger */%0D
 %0A%09privat
@@ -722,16 +722,57 @@
 class);%0D
+%0A%0D%0A%09/** The main frame of this dialog */%0D
 %0A%09privat
@@ -817,16 +817,65 @@
 t...%22);%0D
+%0A%0D%0A%09/** The main content panel of this dialog */%0D
 %0A%09privat
@@ -907,24 +907,51 @@
 w JPanel();%0D
+%0A%0D%0A%09/** The title label */%0D
 %0A%09private st
@@ -979,32 +979,60 @@
 = new JLabel();%0D
+%0A%0D%0A%09/** The author label */%0D
 %0A%09private static
@@ -1065,16 +1065,73 @@
 abel();%0D
+%0A%0D%0A%09/** The area in which to display the license text */%0D
 %0A%09privat
@@ -1182,16 +1182,103 @@
 a();%0D%0A%0D%0A
+%09/**%0D%0A%09 * Runs the body of this task.%0D%0A%09 * This should not be invoked directly.%0D%0A%09 */%0D%0A
 %09@Overri
@@ -2261,16 +2261,64 @@
 %0D%0A%09%7D%0D%0A%0D%0A
+%09/**%0D%0A%09 * Create and show the about box.%0D%0A%09 */%0D%0A
 %09public 
@@ -2384,16 +2384,17 @@
 .%0D%0A%09%09try
+ 
 %7B%0D%0A%09%09%09UI
@@ -2475,16 +2475,120 @@
 %09catch (
+ClassNotFoundException %7C InstantiationException %7C IllegalAccessException%0D%0A%09%09%09%09%09%09%7C UnsupportedLookAndFeel
 Exceptio
@@ -2591,16 +2591,20 @@
 ption e)
+%0D%0A%09%09
 %7B%0D%0A%09%09%09if

Fix multiple PMD errors