Paid for writing

In case you like my writing and would like me to write for your website, then please leave a comment to any of my blog article, mentioning your Email Id and I will reply back. Thanks

Friday, January 30, 2009

Source Code in Java to Dynamically Create and Edit HTML

//EditHtml.java

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class EditHtml implements ActionListener,KeyListener
{
JTextArea contentsArea;
JLabel outputLabel;
JFrame mainFrame;
JSplitPane mainPane;
JScrollPane contentsPane,outputPane;

public EditHtml()
{
contentsArea=new JTextArea(30,30);
contentsArea.addKeyListener(this);
outputLabel=new JLabel();

outputLabel.setAlignmentY(Component.TOP_ALIGNMENT);
outputLabel.setAlignmentX(Component.LEFT_ALIGNMENT);



contentsPane=new JScrollPane(contentsArea);
outputPane=new JScrollPane(outputLabel);


mainFrame=new JFrame();
mainFrame.setTitle("EDIT HTML");


mainPane=new JSplitPane(JSplitPane.VERTICAL_SPLIT,contentsPane,outputPane);

mainFrame.add(mainPane);


mainFrame.pack();
mainFrame.setVisible(true);


}

public static void main(String args[])
{
new EditHtml();
}

public void actionPerformed(ActionEvent ae)
{

}

public void keyPressed(KeyEvent e)
{
}

public void keyReleased(KeyEvent e)
{
}

public void keyTyped(KeyEvent e)
{
outputLabel.setText(contentsArea.getText());
}

}

0 comments: