Thursday, August 5

My Xpad in java...

package xpadbasics;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.Toolkit;
import java.io.*;
import javax.swing.ImageIcon;
import javax.swing.JColorChooser;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
public class Xpad extends javax.swing.JFrame {
Font f;
String s,t;
ImageIcon icon ;
Color c;
int i,j;
Thread thread1 = new Thread();
Date date = new Date();
JColorChooser jcc =new JColorChooser();
public void openFile() {
JFileChooser jfc = new JFileChooser();
jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
jfc.setFileFilter(jfc.getFileFilter());
int result = jfc.showOpenDialog(this);
if (result == JFileChooser.CANCEL_OPTION) {
return;
} else {
try {
FileReader frdr = new FileReader(jfc.getSelectedFile());
BufferedReader brdr = new BufferedReader(frdr);
String s ="";
int c = brdr.read();
while (c != -1) {
s=s+(char)c;
jTextArea1.setText(s);
c = brdr.read();
}
brdr.close();
frdr.close();

} catch (FileNotFoundException e) {
Toolkit.getDefaultToolkit().beep();
JOptionPane.showMessageDialog(this, "Error while loading the file", "ERROR", JOptionPane.ERROR_MESSAGE);
} catch (IOException ex) {
}
}
}
public class abc extends TimerTask{

@Override
public void run() {
jLabel4.setText(""+ date);
jLabel4.repaint();

}
}
public void saveFile() {
JFileChooser jfc = new JFileChooser("C:\\");
jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
int result = jfc.showSaveDialog(this);
if (result == JFileChooser.CANCEL_OPTION) {
return;
} else {
try {
FileOutputStream fos = new FileOutputStream(jfc.getSelectedFile()+ ".rtf");
BufferedOutputStream bos = new BufferedOutputStream(fos);
bos.write(jTextArea1.getText().getBytes());
bos.flush();
fos.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(this, "Error while saving file!", "Error", JOptionPane.ERROR_MESSAGE);
}
}
}
public Xpad() {
initComponents();
}
@SuppressWarnings("unchecked")
//
private void initComponents() {

jComboBox1 = new javax.swing.JComboBox();
jComboBox2 = new javax.swing.JComboBox();
jComboBox3 = new javax.swing.JComboBox();
jLabel1 = new javax.swing.JLabel();
jSlider1 = new javax.swing.JSlider();
jLabel2 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
jProgressBar1 = new javax.swing.JProgressBar();
jButton3 = new javax.swing.JButton();
jScrollPane2 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jLabel5 = new javax.swing.JLabel();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
jMenuItem3 = new javax.swing.JMenuItem();
jMenuItem4 = new javax.swing.JMenuItem();
jMenuItem5 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
jMenuItem6 = new javax.swing.JMenuItem();
jMenuItem7 = new javax.swing.JMenuItem();
jMenuItem8 = new javax.swing.JMenuItem();
jMenuItem9 = new javax.swing.JMenuItem();
jMenuItem10 = new javax.swing.JMenuItem();
jMenuItem11 = new javax.swing.JMenuItem();
jMenuItem12 = new javax.swing.JMenuItem();
jMenu4 = new javax.swing.JMenu();
jMenuItem21 = new javax.swing.JMenuItem();
jMenuItem22 = new javax.swing.JMenuItem();
jMenuItem13 = new javax.swing.JMenuItem();
jMenu3 = new javax.swing.JMenu();
jMenuItem14 = new javax.swing.JMenuItem();
jMenuItem15 = new javax.swing.JMenuItem();
jMenuItem23 = new javax.swing.JMenuItem();
jMenuItem24 = new javax.swing.JMenuItem();
jMenuItem28 = new javax.swing.JMenuItem();
jMenu5 = new javax.swing.JMenu();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("X-Pad");
setBackground(new java.awt.Color(204, 204, 255));
setLocationByPlatform(true);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}
});

jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Arial", "Arial Black", "Monotype Corsiva", "Calibri", "Times New Roman", "Helvetica", " " }));
jComboBox1.setPreferredSize(new java.awt.Dimension(20, 20));
jComboBox1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox1ActionPerformed(evt);
}
});

jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Regular", "Bold", "Italic", "Underline", "Bold + Italic", "Bold + Underline", "Italic + Underline", " ", " ", " " }));
jComboBox2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox2ActionPerformed(evt);
}
});

jComboBox3.setEditable(true);
jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "17", "5", "8", "10", "11", "12", "13", "14", "15", "16", "18", "20", "22", "24", "26", "30", "32", "48", "56", "72" }));
jComboBox3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox3ActionPerformed(evt);
}
});

jLabel1.setText("Characters: ");

jSlider1.setMaximum(200);
jSlider1.setValue(17);
jSlider1.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
jSlider1StateChanged(evt);
}
});

jLabel2.setOpaque(true);

jButton1.setText("jButton1");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jLabel4.setText("..");

jButton2.setText("jButton2");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

jProgressBar1.setBackground(new java.awt.Color(255, 0, 51));
jProgressBar1.setMaximum(10000000);

jButton3.setText("jButton3");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});

jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jTextArea1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jTextArea1MouseClicked(evt);
}
});
jTextArea1.addCaretListener(new javax.swing.event.CaretListener() {
public void caretUpdate(javax.swing.event.CaretEvent evt) {
jTextArea1CaretUpdate(evt);
}
});
jTextArea1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
public void mouseDragged(java.awt.event.MouseEvent evt) {
jTextArea1MouseDragged(evt);
}
});
jScrollPane2.setViewportView(jTextArea1);

jLabel5.setText("Lines:");

jMenu1.setText("File");

jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem1.setText("New");
jMenu1.add(jMenuItem1);

jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem2.setText("Open");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem2);

jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem3.setText("Save");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem3);

jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F2, 0));
jMenuItem4.setText("Save As...");
jMenu1.add(jMenuItem4);

jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem5.setText("Exit");
jMenu1.add(jMenuItem5);

jMenuBar1.add(jMenu1);

jMenu2.setText("Edit");

jMenuItem6.setText("Cut");
jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem6ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem6);

jMenuItem7.setText("Copy");
jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem7ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem7);

jMenuItem8.setText("Paste");
jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem8ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem8);

jMenuItem9.setText("Undo");
jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem9ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem9);

jMenuItem10.setText("Redo");
jMenu2.add(jMenuItem10);

jMenuItem11.setText("Select All");
jMenuItem11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem11ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem11);

jMenuItem12.setText("Delete");
jMenuItem12.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem12ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem12);

jMenuBar1.add(jMenu2);

jMenu4.setText("Format");
jMenu4.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jMenu4MouseClicked(evt);
}
});

jMenuItem21.setText("LowerCase");
jMenuItem21.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem21ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem21);

jMenuItem22.setText("UpperCase");
jMenuItem22.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem22ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem22);

jMenuItem13.setText("Wrap");
jMenuItem13.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jMenuItem13MouseClicked(evt);
}
});
jMenuItem13.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem13ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem13);

jMenu3.setText("Selected Word Count");

jMenuItem14.setText("Exact Selected text");
jMenuItem14.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem14ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem14);

jMenuItem15.setText("Ignore case of Selected text");
jMenuItem15.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem15ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem15);

jMenu4.add(jMenu3);

jMenuItem23.setText("Set Background");
jMenuItem23.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem23ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem23);

jMenuItem24.setText("Encrypt");
jMenuItem24.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem24ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem24);

jMenuItem28.setText("Decrypt");
jMenuItem28.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem28ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem28);

jMenuBar1.add(jMenu4);

jMenu5.setText("Help");
jMenuBar1.add(jMenu5);

setJMenuBar(jMenuBar1);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, 479, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 205, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel5)
.addGap(58, 58, 58)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 87, Short.MAX_VALUE)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 601, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton3)
.addGap(83, 83, 83)
.addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 469, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 1062, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(13, 13, 13)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2)
.addComponent(jButton3)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jSlider1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 634, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 11, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
.addComponent(jLabel5))
.addContainerGap())
);

pack();
}//

private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {
openFile();
}
private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {
int fontstyle = jTextArea1.getFont().getStyle();
f=new Font(jComboBox1.getSelectedItem().toString(), fontstyle,Integer.valueOf(jComboBox3.getSelectedItem().toString()));
jTextArea1.setFont(f);
}
private void jComboBox3ActionPerformed(java.awt.event.ActionEvent evt) {
int fontstyle = jTextArea1.getFont().getStyle();
f=new Font(jComboBox1.getSelectedItem().toString(), fontstyle,Integer.valueOf(jComboBox3.getSelectedItem().toString()));
jTextArea1.setFont(f);
jSlider1.setValue((Integer.valueOf(jComboBox3.getSelectedItem().toString())));
}
private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) {
if((jComboBox2.getSelectedItem().toString()).equals("Bold"))
{
f=new Font(jComboBox1.getSelectedItem().toString(), Font.BOLD,Integer.valueOf(jComboBox3.getSelectedItem().toString()));
jTextArea1.setFont(f);
}
if((jComboBox2.getSelectedItem().toString().equalsIgnoreCase("Italic")))
{ f=new Font(jComboBox1.getSelectedItem().toString(), Font.ITALIC,Integer.valueOf(jComboBox3.getSelectedItem().toString()));
jTextArea1.setFont(f);
}
if((jComboBox2.getSelectedItem().toString().equalsIgnoreCase("Regular")))
{ f=new Font(jComboBox1.getSelectedItem().toString(), Font.PLAIN,Integer.valueOf(jComboBox3.getSelectedItem().toString()));
jTextArea1.setFont(f);
}
}
private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {
jTextArea1.cut();
}
private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {
jTextArea1.copy();
}
private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {
jTextArea1.paste();
}
private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {
}
private void jMenuItem11ActionPerformed(java.awt.event.ActionEvent evt) {
jTextArea1.selectAll();
}
private void jMenuItem12ActionPerformed(java.awt.event.ActionEvent evt) {
jTextArea1.replaceSelection("");
}
private void jMenuItem21ActionPerformed(java.awt.event.ActionEvent evt) {
jTextArea1.replaceSelection(jTextArea1.getSelectedText().toLowerCase());
}
private void jMenuItem22ActionPerformed(java.awt.event.ActionEvent evt) {
jTextArea1.replaceSelection(jTextArea1.getSelectedText().toUpperCase());
}
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {
saveFile();
}
private void jSlider1StateChanged(javax.swing.event.ChangeEvent evt) {
int fontstyle = jTextArea1.getFont().getStyle();
f=new Font(jComboBox1.getSelectedItem().toString(),fontstyle,jSlider1.getValue());
jTextArea1.setFont(f);
jComboBox3.setSelectedItem(jSlider1.getValue());
}
private void formWindowOpened(java.awt.event.WindowEvent evt) {
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Timer a =new Timer();
a.scheduleAtFixedRate(new abc(), 1000, 1000);
}
private void jMenuItem23ActionPerformed(java.awt.event.ActionEvent evt) {
c = JColorChooser.showDialog(((Component)evt.getSource()).getParent(),"X-Pad Color Table", Color.blue);
jTextArea1.setBackground(c);
}
private void jMenuItem24ActionPerformed(java.awt.event.ActionEvent evt) {
s=jTextArea1.getText();
t="";
char d;
for(i=0;i { d = s.charAt(i);
t+=(char)((int)d + 38);
}
jTextArea1.setText(t);
}
private void jMenuItem28ActionPerformed(java.awt.event.ActionEvent evt) {
s=jTextArea1.getText();
t="";
char d;
for(i=0;i{ d = s.charAt(i);
t+=(char)((int)d - 38);
}
jTextArea1.setText(t);
}
private void jMenuItem14ActionPerformed(java.awt.event.ActionEvent evt) {
try
{
jLabel3.setVisible(true);
int k,l=0;
t= jTextArea1.getSelectedText();
s=jTextArea1.getText();
for(i=0;i{
if(t.charAt(0)==s.charAt(i))
{
k=i;
for(j=0;j {
if(t.charAt(j)==s.charAt(k))
{
k++;
}
else
{
break;
}
}
if(j==t.length())
{
l++;
}
}
}
jLabel3.setText("|| " + t +" ||" + " (Your Selected Text) "+" is " + l + " times in this File!!");
}
catch (Exception ae){}
}

private void jMenuItem15ActionPerformed(java.awt.event.ActionEvent evt) {

}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
//JOptionPane.showMessageDialog(null, date, "Today's Date is", WIDTH); // TODO add your handling code here;

}

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

for(i=0;i<=jProgressBar1.getMaximum();i++)
{
jProgressBar1.setValue(i);
jProgressBar1.setValue(i);
jProgressBar1.repaint();
}
}

private void jTextArea1CaretUpdate(javax.swing.event.CaretEvent evt) {
jLabel1.setText("Characters: " + jTextArea1.getText().length());
jLabel5.setText("Lines:"+jTextArea1.getLineCount());
}

private void jTextArea1MouseClicked(java.awt.event.MouseEvent evt) {
jLabel2.setVisible(false);
jLabel3.setVisible(false);
}

private void jTextArea1MouseDragged(java.awt.event.MouseEvent evt) {
try {
jLabel2.setVisible(true);
jLabel2.setText(String.valueOf("Selected Characters: "+jTextArea1.getSelectedText().length()));
}catch (Exception ae){}
}

private void jMenu4MouseClicked(java.awt.event.MouseEvent evt) {
if(jTextArea1.getWrapStyleWord())
jMenuItem13.setText("UnWrap");
else jMenuItem13.setText("Wrap");
}

private void jMenuItem13MouseClicked(java.awt.event.MouseEvent evt) {

}

private void jMenuItem13ActionPerformed(java.awt.event.ActionEvent evt) {
if (jTextArea1.getWrapStyleWord()==false)
{
jTextArea1.setLineWrap(true);
jTextArea1.setWrapStyleWord(true); // TODO add your handling code here:
}
else {
jTextArea1.setLineWrap(false);
jTextArea1.setWrapStyleWord(false);
}
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Xpad().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JComboBox jComboBox2;
private javax.swing.JComboBox jComboBox3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu3;
private javax.swing.JMenu jMenu4;
private javax.swing.JMenu jMenu5;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem10;
private javax.swing.JMenuItem jMenuItem11;
private javax.swing.JMenuItem jMenuItem12;
private javax.swing.JMenuItem jMenuItem13;
private javax.swing.JMenuItem jMenuItem14;
private javax.swing.JMenuItem jMenuItem15;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem21;
private javax.swing.JMenuItem jMenuItem22;
private javax.swing.JMenuItem jMenuItem23;
private javax.swing.JMenuItem jMenuItem24;
private javax.swing.JMenuItem jMenuItem28;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JMenuItem jMenuItem5;
private javax.swing.JMenuItem jMenuItem6;
private javax.swing.JMenuItem jMenuItem7;
private javax.swing.JMenuItem jMenuItem8;
private javax.swing.JMenuItem jMenuItem9;
private javax.swing.JProgressBar jProgressBar1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JSlider jSlider1;
private javax.swing.JTextArea jTextArea1;
// End of variables declaration
}