/****************************************
*HTMLGen.java
*From http://home.att.net/~gobruen
*
* Called by MainInterface.java
* Opens an interface for entering text and settings
* that will go into an HTML file.
* The file content is generated by Hlib.java
*
*
* HTMLGen()
* reset()
* actionPerformed()
* genHTMLFile()
*
*
*****************************************/
import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.awt.event.*;
public class HTMLGen extends JFrame implements ActionListener
{
private JLabel fnLabel = new JLabel("File Name:", JLabel.LEFT);
private JLabel tLabel = new JLabel("Title:", JLabel.LEFT);
private JLabel mdLabel = new JLabel("Meta Data:", JLabel.LEFT);
private JLabel bgLabel = new JLabel("Background Color:", JLabel.LEFT);
private JLabel tcLabel = new JLabel("Text Color:", JLabel.LEFT);
private JLabel tfLabel = new JLabel("Text Font:", JLabel.LEFT);
private JLabel glLabel = new JLabel("General Link:", JLabel.LEFT);
private JLabel glnLabel = new JLabel("General Link Name:", JLabel.LEFT);
private JLabel imgLabel = new JLabel("Image:", JLabel.LEFT);
private JTextField fnameField = new JTextField(20);//file name
private JTextField titleP = new JTextField(20);//page title
private JTextField mData = new JTextField(20);//meta data
private JTextField bgColor = new JTextField(20);//background color
private JTextField tColor = new JTextField(20);//text color
private JTextField tFont = new JTextField(20);//text font
private JTextField genLink = new JTextField(20);//text color
private JTextField genLinkN = new JTextField(20);//text font
private JTextField img = new JTextField(20);//image
private JTextArea paragContent = new JTextArea();
private JButton genHTMLBut = new JButton("Publish"); //See detailed
private JButton launchBut = new JButton("Launch"); //descriptions
private JButton helpBut = new JButton("Help"); //for these
private JButton addPara = new JButton("Add Paragraph"); //functions
private JPanel commands = new JPanel();
private JPanel create = new JPanel();
private int max = 10;
private int pCnt = 0;
private String paragArr[] = new String[max];
public HTMLGen()
{
super("HTML Page Maker");
commands.setLayout(new GridLayout(9, 1));
fnLabel.setFont(new Font("Courier", Font.BOLD, 15));
fnameField.setToolTipText("Your file name, leave out .html");
fnameField.setFont(new Font("Courier", Font.BOLD, 15));
commands.add(fnLabel);
commands.add(fnameField);
paragContent.setFont(new Font("Courier", Font.BOLD, 20));
paragContent.setToolTipText("Enter you text content here, press Add Paragraph for a new paragraph");
titleP.setFont(new Font("Courier", Font.BOLD, 15));
titleP.setToolTipText("Page title");
titleP.setFont(new Font("Courier", Font.BOLD, 15));
commands.add(tLabel);
commands.add(titleP);
tLabel.setFont(new Font("Courier", Font.BOLD, 15));
mData.setToolTipText("enter meta data or keywords. These are hidden, not displayed on page");
mData.setFont(new Font("Courier", Font.BOLD, 15));
commands.add(mdLabel);
commands.add(mData);
mdLabel.setFont(new Font("Courier", Font.BOLD, 15));
bgColor.setToolTipText("Page background color");
bgColor.setFont(new Font("Courier", Font.BOLD, 15));
commands.add(bgLabel);
commands.add(bgColor);
bgLabel.setFont(new Font("Courier", Font.BOLD, 15));
bgColor.setToolTipText("");
bgColor.setFont(new Font("Courier", Font.BOLD, 15));
commands.add(tcLabel);
commands.add(tColor);
tcLabel.setFont(new Font("Courier", Font.BOLD, 15));
tColor.setToolTipText("Page text color");
tColor.setFont(new Font("Courier", Font.BOLD, 15));
commands.add(tfLabel);
commands.add(tFont);
tfLabel.setFont(new Font("Courier", Font.BOLD, 15));
tFont.setToolTipText("Page text font");
tFont.setFont(new Font("Courier", Font.BOLD, 15));
commands.add(glLabel);
commands.add(genLink);
glLabel.setFont(new Font("Courier", Font.BOLD, 15));
genLink.setToolTipText("Enter the full URL, ex: http://www.yahoo.com");
genLink.setFont(new Font("Courier", Font.BOLD, 15));
commands.add(glnLabel);
commands.add(genLinkN);
glnLabel.setFont(new Font("Courier", Font.BOLD, 15));
genLinkN.setToolTipText("Enter the name of the above link, ex: Yahoo!");
genLinkN.setFont(new Font("Courier", Font.BOLD, 15));
commands.add(imgLabel);
commands.add(img);
imgLabel.setFont(new Font("Courier", Font.BOLD, 15));
img.setToolTipText("Enter the name of an image file, include the file extension, ex: .jpg, .gif");
img.setFont(new Font("Courier", Font.BOLD, 15));
paragContent.setLineWrap(true);
genHTMLBut.addActionListener(this);
genHTMLBut.setForeground(Color.black);
genHTMLBut.setFont(new Font("Courier", Font.BOLD,10));
create.add(genHTMLBut);
addPara.addActionListener(this);
addPara.setForeground(Color.black);
addPara.setFont(new Font("Courier", Font.BOLD,10));
create.add(addPara);
launchBut.addActionListener(this);
launchBut.setForeground(Color.black);
launchBut.setFont(new Font("Courier", Font.BOLD,10));
create.add(launchBut);
helpBut.addActionListener(this);
helpBut.setForeground(Color.black);
helpBut.setFont(new Font("Courier", Font.BOLD,10));
create.add(helpBut);
Container c = getContentPane();
c.setLayout(new BorderLayout());
c.add("North", commands);
c.add("South", create);
c.add(new JScrollPane(paragContent));
c.add("Center", paragContent);
}//end con HTMLGen()
/****************************
*
* reset()
* Sets all the Jtext fields and other parameters
* back to blank or 0 to create a new page
*
*****************************/
public void reset(){
paragContent.setText("");
fnameField.setText("");
titleP.setText("");
mData.setText("");
bgColor.setText("");
tColor.setText("");
tFont.setText("");
genLink.setText("");
genLinkN.setText("");
img.setText("");
for(int i=0; i