Editor Example

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.util.Date;
import java.util.Calendar;
public class EditorAnu implements ActionListener,KeyListener
{
Frame f1 ;
Frame f2 ;
Container c,d;
TextArea tr;
TextArea ta;
MenuBar mb;
JToolBar tb;
Button nb;
Menu file,edit,changecase,view,insert,search,text,layout,project,spro,mpro,window,help;
JDialog dd=new JDialog( f1,"Find",false);
BufferedReader br = null;
JDialog dg = new JDialog( f1,"Open New Page",false);
Label label = new Label (" Do you want to save the changes?");
Label lab = new Label (" ");
Button b1 = new Button(" Yes ");
Button b0 = new Button(" No ");
Button b2 = new Button(" Cancel ");
JDialog ag;
JDialog fg;
JDialog rg;
JDialog rok;
Button bt,but,bok,bcancel,brgc,bag;
Button bk = new Button(" OK ");
Button fb1;
Button fb2;
Button bc;
Button br1;
MenuItem mnew = new MenuItem("New...");
MenuItem open = new MenuItem("Open...");
MenuItem close = new MenuItem("Close");
MenuItem save = new MenuItem("Save...");
MenuItem print = new MenuItem("Print...");
MenuItem cut = new MenuItem("Cut");
MenuItem copy = new MenuItem("Copy");
MenuItem delete = new MenuItem("Delete");
MenuItem sa = new MenuItem("SelectAll");
MenuItem lc = new MenuItem("LowerCase");
MenuItem uc = new MenuItem("UpperCase");
MenuItem td = new MenuItem("Time/Date");
MenuItem browser = new MenuItem("Browser...");
MenuItem img = new MenuItem("Image...");
MenuItem paste = new MenuItem("Paste");
MenuItem rename = new MenuItem("Replace...");
MenuItem exit = new MenuItem("Exit");
MenuItem find = new MenuItem("Find...");
MenuItem font = new MenuItem("Font...");
MenuItem background=new MenuItem("Background...");
MenuItem dpro=new MenuItem(".Default Project");
MenuItem apro=new MenuItem("Add to Project");
MenuItem epro=new MenuItem("Edit Project");
MenuItem cpro=new MenuItem("Close Project");
MenuItem next=new MenuItem("Next");
MenuItem prv=new MenuItem("Previous");
MenuItem about=new MenuItem("About");

MenuItem lineno=new MenuItem("LineNo");

FileDialog fd;
FileDialog ff;
String msg,line;
Date date;
GregorianCalendar gcal;
GridBagLayout gb ;
GridBagConstraints gbc;
Container e ;
JDialog dm ;
JDialog fr;
JColorChooser color;
TextField tf,t1,t2,t3,t4,trc;
JPasswordField psw;
Label l,l1,l2,l3,l4,lp,lrc,lpsw,lp1;
Button b3,b4;
Font f;
FileInputStream inp = null;
EditorAnu()
{
f1 = new Frame("My Editor");
f1.setVisible(true);
f1.setSize(600,400);
f1.setBackground(Color.gray);
ta = new TextArea ("" ,500,500,TextArea.SCROLLBARS_BOTH);
mb = new MenuBar();
tb=new JToolBar();
nb=new Button("New");
file = new Menu("File");
edit = new Menu("Edit");
changecase=new Menu("ChangeCase");
view = new Menu("View");
insert = new Menu("Insert");
search = new Menu("Search");
text = new Menu("Text ");
layout = new Menu("Layout");
project = new Menu("Project");
spro = new Menu("Slect Project");
mpro = new Menu("Manage Project");
window = new Menu("Window");
help = new Menu("Help");

tb.add(nb);
mb.add(file);
mb.add(edit);
mb.add(view);
mb.add(insert);
mb.add(search);
mb.add(text);
mb.add(layout);
mb.add(project);
mb.add(window);
mb.add(help);

file.add(mnew);
file.add(open);
file.add(close);
file.add(save);
file.add(print);
file.add(exit);
edit.add(cut);
edit.add(copy);
edit.add(delete);
edit.add(sa);
edit.add(changecase);
changecase.add(lc);
changecase.add(uc);
edit.add(td);
view.add(browser);
insert.add(img);
text.add(paste);
text.add(font);
layout.add(find);
layout.add(rename);
layout.add(background);
project.add(spro);
spro.add(dpro);
project.add(mpro);
mpro.add(apro);
mpro.add(epro);
mpro.add(cpro);
window.add(next);
window.add(prv);
help.add(about);

help.add(lineno);

gb = new GridBagLayout();
gbc = new GridBagConstraints();
fg=new JDialog(f1,"Registration Copy",false);
JLabel label12 = new JLabel ("Arti's EditPlus ");
Label labelcd=new Label("This product is licensed to:");
Label labelde=new Label("Arti & Company");
Label labeldf=new Label("Click on Agree Button to Proceed");
Label labelgh=new Label("-----------------------------------------------------------------");
Label label34=new Label("Arti and Anurag");
bag=new Button(" Agree ");

e = fg.getContentPane();
f1.add(ta);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 1;
gbc.gridy = 4;
gb.setConstraints(labelcd,gbc);
e.add(labelcd);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 1;
gbc.gridy = 5;
gb.setConstraints(labelde,gbc);
e.add(labelde);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 1;
gbc.gridy = 6;
gb.setConstraints(labeldf,gbc);
e.add(labeldf);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 1;
gbc.gridy = 7;
gb.setConstraints(labelgh,gbc);
e.add(labelgh);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 1;
gbc.gridy = 8;
gb.setConstraints(label34,gbc);
e.add(label34);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 1;
gbc.gridy = 11;
gb.setConstraints(bag,gbc);
e.add(bag);

e.setLayout(gb);
fg.setVisible(true);
fg.setSize(100,100);
fg.setBounds(100,100,100,100);
fg.pack();

dm = new JDialog(f1,"Set Fonts",false);
t1 = new TextField(10);
t2 = new TextField(10);
t3 = new TextField(10);
t4 = new TextField(10);

l1 = new Label("Font Name");
l2 = new Label("Style");
l3 = new Label("Size");
l4 = new Label("Color");

b3 = new Button("OK");
b4 = new Button("Cancel");
f1.add(ta);
e = dm.getContentPane();

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 0;
gbc.gridy = 0;
gb.setConstraints(l1,gbc);
e.add(l1);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 0;
gbc.gridy = 1;
gb.setConstraints(l2,gbc);
e.add(l2);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 0;
gbc.gridy = 2;
gb.setConstraints(l3,gbc);
e.add(l3);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 0;
gbc.gridy = 3;
gb.setConstraints(l4,gbc);
e.add(l4);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 3;
gbc.gridy = 0;
gb.setConstraints(t1,gbc);
e.add(t1);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 3;
gbc.gridy = 1;
gb.setConstraints(t2,gbc);
e.add(t2);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 3;
gbc.gridy = 2;
gb.setConstraints(t3,gbc);
e.add(t3);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 3;
gbc.gridy = 3;
gb.setConstraints(t4,gbc);
e.add(t4);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 2;
gbc.gridy = 6;
gb.setConstraints(b3,gbc);
e.add(b3);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 3;
gbc.gridy = 6;
gb.setConstraints(b4,gbc);
e.add(b4);
e.setLayout(gb);

e = dg.getContentPane();

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 1;
gbc.gridy = 0;
gb.setConstraints(label,gbc);
e.add(label);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 1;
gbc.gridy = 1;
gb.setConstraints(lab,gbc);
e.add(lab);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 0;
gbc.gridy = 2;
gb.setConstraints(b1,gbc);
e.add(b1);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 1;
gbc.gridy = 2;
gb.setConstraints(b0,gbc);
e.add(b0);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 2;
gbc.gridy = 2;
gb.setConstraints(b2,gbc);
e.add(b2);
e.setLayout(gb);

ag=new JDialog(f1,"About EditPlus++",false);
Label label1 = new Label ("Arti's Editor ");

Label label0=new Label("Copyright=====>Arti & Co Pvt Ltd.");
Label labela=new Label("**************************************");
Label labelc=new Label("This product is licensed to:");
Label labeld=new Label("Arti and Anurag");

Label labelg=new Label("===============");
Label label3=new Label("This product devloped by Anurag with Company of ARTI");

bt=new Button("Click Me...");
e = ag.getContentPane();

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 1;
gbc.gridy = 0;
gb.setConstraints(label1,gbc);
e.add(label1);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 1;
gbc.gridy = 2;
gb.setConstraints(label0,gbc);
e.add(label0);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 1;
gbc.gridy = 3;
gb.setConstraints(labela,gbc);
e.add(labela);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 1;
gbc.gridy = 4;
gb.setConstraints(labelc,gbc);
e.add(labelc);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 1;
gbc.gridy = 5;
gb.setConstraints(labeld,gbc);
e.add(labeld);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 1;
gbc.gridy = 7;
gb.setConstraints(labelg,gbc);
e.add(labelg);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 1;
gbc.gridy = 8;
gb.setConstraints(label3,gbc);
e.add(label3);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 3;
gbc.gridy = 10;
gb.setConstraints(bt,gbc);
e.add(bt);
e.setLayout(gb);

e = dd.getContentPane();
Label label8 = new Label("Find What");
Label label9 = new Label("Direction");
TextField t1 = new TextField(10);
fb1 = new Button ("Find Next");
fb2 = new Button ("Cancel");
JCheckBox cb = new JCheckBox("Match Case");
ButtonGroup bp = new ButtonGroup();
JRadioButton rb1 = new JRadioButton("up");
JRadioButton rb2 = new JRadioButton("down");
bp.add(rb1);
bp.add(rb2);

gbc.anchor = GridBagConstraints.NORTH ;
gbc.gridx = 0;
gbc.gridy = 0;
gb.setConstraints(label8,gbc);
e.add(label8);

gbc.anchor = GridBagConstraints.NORTH ;
gbc.gridx = 3;
gbc.gridy = 0;
gb.setConstraints(t1,gbc);
e.add(t1);


gbc.anchor = GridBagConstraints.NORTH ;
gbc.gridx = 3;
gbc.gridy = 3;
gb.setConstraints(label9,gbc);
e.add(label9);

gbc.anchor = GridBagConstraints.NORTH ;
gbc.gridx = 5;
gbc.gridy = 0;
gb.setConstraints(fb1,gbc);
e.add(fb1);

gbc.anchor = GridBagConstraints.NORTH ;
gbc.gridx = 5;
gbc.gridy = 2;
gb.setConstraints(fb2,gbc);
e.add(fb2);

gbc.anchor = GridBagConstraints.NORTH ;
gbc.gridx = 0;
gbc.gridy = 6;
gb.setConstraints(cb,gbc);
e.add(cb);

gbc.anchor = GridBagConstraints.NORTH ;
gbc.gridx = 3;
gbc.gridy = 5;
gb.setConstraints(rb1,gbc);
e.add(rb1);

gbc.anchor = GridBagConstraints.NORTH ;
gbc.gridx = 4;
gbc.gridy = 5;
gb.setConstraints(rb2,gbc);
e.add(rb2);
e.setLayout(gb);


fr = new JDialog(f1,"Replace",false);
tf = new TextField(20);
l = new Label("Replace With:");
br1 = new Button("Replace");
bc = new Button("Cancel");

e = fr.getContentPane();
gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 0;
gbc.gridy = 0;
gb.setConstraints(l,gbc);
e.add(l);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 2;
gbc.gridy = 0;
gb.setConstraints(tf,gbc);
e.add(tf);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 2;
gbc.gridy = 2;
gb.setConstraints(br1,gbc);
e.add(br1);

gbc.anchor = GridBagConstraints.NORTH;
gbc.gridx = 3;
gbc.gridy = 2;
gb.setConstraints(bc,gbc);
e.add(bc);
e.setLayout(gb);

mnew.addActionListener(this);
b1.addActionListener(this);
b0.addActionListener(this);
b2.addActionListener(this);
save.addActionListener(this);
print.addActionListener(this);
open.addActionListener(this);
close.addActionListener(this);
cut.addActionListener(this);
copy.addActionListener(this);
delete.addActionListener(this);
sa.addActionListener(this);
lc.addActionListener(this);
uc.addActionListener(this);
td.addActionListener(this);
browser.addActionListener(this);
img.addActionListener(this);
paste.addActionListener(this);
rename.addActionListener(this);
br1.addActionListener(this);
bc.addActionListener(this);
exit.addActionListener(this);
find.addActionListener(this);
fb1.addActionListener(this);
fb2.addActionListener(this);
cb.addActionListener(this);
rb1.addActionListener(this);
rb2.addActionListener(this);
font.addActionListener(this);
background.addActionListener(this);
dpro.addActionListener(this);
apro.addActionListener(this);
epro.addActionListener(this);
cpro.addActionListener(this);
next.addActionListener(this);
prv.addActionListener(this);
about.addActionListener(this);
bag.addActionListener(this);
bk.addActionListener(this);
bt.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);

lineno.addActionListener(this);

/*mnew.addKeyListener(this);
save.addKeyListener(this);
open.addKeyListener(this);
cut.addKeyListener(this);
copy.addKeyListener(this);
delete.addKeyListener(this);
paste.addKeyListener(this);
rename.addKeyListener(this);
exit.addKeyListener(this);
find.addKeyListener(this);
background.addKeyListener(this);
font.addKeyListener(this);*/
b3.addKeyListener(this);
b4.addKeyListener(this);

f1.setMenuBar(mb);
f1.pack();

}
public static void main(String aad[])
{
EditorAnu arti = new EditorAnu();
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == mnew )
{
dg.setVisible(true);
dg.setSize(100,100);
dg.setBounds(100,100,100,100);
dg.pack();
/*System.out.println("Hello");
f2 = new Frame ("hello");
f2 .setVisible(true);
f2.setSize(500,500);
f2.getContentPane().add(tr);

MenuBar mb = new MenuBar();

Menu file = new Menu("file");
Menu edit = new Menu("edit");
Menu text = new Menu("text ");
Menu layout = new Menu("layout");

MenuItem mnew = new MenuItem("new");
MenuItem open = new MenuItem("open");
MenuItem save = new MenuItem("save");
MenuItem cut = new MenuItem("cut");
MenuItem copy = new MenuItem("copy");
MenuItem paste = new MenuItem("paste");
MenuItem font=new MenuItem("font");
MenuItem rename = new MenuItem("rename");
MenuItem exit = new MenuItem("exit");
MenuItem find = new MenuItem("find");
MenuItem bg=new MenuItem("Background");
mb.add(file);
mb.add(edit);
mb.add(text);
mb.add(layout);
file.add(mnew);
file.add(open);
file.add(save);
file.add(exit);
edit.add(cut);
edit.add(copy);
text.add(paste);
text.add(font);
layout.add(rename);
layout.add(find);
layout.add(bg);


f2.setMenuBar(mb);*/
}
if(e.getSource() == b1 )
{
ff = new FileDialog(f1,"Save a file",1);
ff.setVisible(true);
String fl = ff.getDirectory() + ff.getFile();
byte line[]=ta.getText().getBytes();
try
{
FileOutputStream in = new FileOutputStream(fl);
in.write(line);
in.close();
}
catch(Exception el)
{
System.out.println(el);
}
}
if(e.getSource() == b0 )
{
msg = ta.getText();
ta.setText("");
ta.setBackground(Color.white);
dg.dispose();
}
if(e.getSource() == b2 )
{
dg.dispose();
}
if(e.getSource() == open )
{
System.out.println("hello");
fd = new FileDialog(f1,"Open a file",0);
fd.setVisible(true);
String fl = fd.getDirectory() + fd.getFile();
ta.setText(" ");
try
{
inp = new FileInputStream(fl);
br = new BufferedReader (new InputStreamReader(inp));
String line;
while((line = br.readLine()) != null )
{
ta.setText(ta.getText() + "\n" + line);
}
inp.close();
}
catch(Exception rt)
{
}

}
if(e.getSource() == close )
{
msg = ta.getText();
ta.setText("");
}
if(e.getSource() == exit )
{
System.exit(0);
}

if(e.getSource() == bag )
{
fg.dispose();
}
if(e.getSource() == save )
{
ff = new FileDialog(f1,"Save a file",1);
ff.setVisible(true);
String fl = ff.getDirectory() + ff.getFile();
byte line[]=ta.getText().getBytes();
try
{
FileOutputStream in = new FileOutputStream(fl);
in.write(line);
in.close();
}
catch(Exception el)
{
System.out.println(el);
}

}
if(e.getSource() == print)
{

}
if(e.getSource() == cut)
{

msg = ta.getSelectedText();
//ta.setText("");
}
if(e.getSource() == paste )
{
ta.setText(ta.getText() + msg );
}
if(e.getSource() == copy)
{
msg = ta.getSelectedText();
}
if(e.getSource() == delete)
{
msg = ta.getSelectedText();
ta.setText("");
}
if(e.getSource() == sa)
{
msg=ta.getText();
ta.setText(ta.getText()+msg);
}
if(e.getSource() == lc)
{
msg=ta.getSelectedText();
ta.setText(msg.toLowerCase());
}
if(e.getSource() == uc)
{
msg=ta.getSelectedText();
ta.setText(msg.toUpperCase());
}
if(e.getSource() == td)
{
date=new Date();
gcal=new GregorianCalendar();
gcal.setTime(date);
msg=gcal.get(Calendar.HOUR)+":"+gcal.get(Calendar.MINUTE)+":"+gcal.get(Calendar.SECOND)+" "+gcal.get(Calendar.MONTH)+"/"+gcal.get(Calendar.DATE)+"/"+gcal.get(Calendar.YEAR);
ta.setText(msg);
}
if(e.getSource() == browser)
{
}
if(e.getSource() == img)
{
fd = new FileDialog(f1,"Browse a image",0);
fd.setVisible(true);
String fl = fd.getDirectory() + fd.getFile();
ta.setText(" ");
try
{
inp = new FileInputStream(fl);
br = new BufferedReader (new InputStreamReader(inp));
String line;
while((line = br.readLine()) != null )
{
ta.setText(ta.getText() + "\n" + line);
}
inp.close();
}
catch(Exception rt)
{
}
}
if(e.getSource() == font)
{

dm.setVisible(true);
dm.setSize(100,100);
dm.setBounds(100,100,100,100);
dm.pack();

}

if(e.getSource() == bcancel)
{
rg.dispose();
}
if(e.getSource() == rename)
{
fr.setVisible(true);
fr.setSize(100,100);
fr.setBounds(100,100,100,100);
fr.pack();
}
if(e.getSource() == bc)
{
fr.dispose();
}
if(e.getSource() == br1)
{

}
if(e.getSource() == background)
{
f1.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
Color color=JColorChooser.showDialog(f1,"Background Colors",ta.getBackground());
ta.setBackground(color);
ta.repaint();
}
if(e.getSource() == about)
{

ag.setVisible(true);
ag.setSize(200,200);
ag.setBounds(200,200,200,200);
ag.pack();

}
if(e.getSource() == lineno)
{
FileReader fileReader = null;
BufferedReader bufferedReader = null;
LineNumberReader lineNumberReader = null;
String line1;
byte line[]=ta.getText().getBytes();
try
{
FileOutputStream in = new FileOutputStream("temp.txt");
in.write(line);
in.close();
}
catch(Exception el)
{
System.out.println(el);
}

try
{
fileReader = new FileReader ("temp.txt");
bufferedReader = new BufferedReader (fileReader);
lineNumberReader = new LineNumberReader (bufferedReader);
while ((line1 = lineNumberReader.readLine()) != null)
{
int lineNo = lineNumberReader.getLineNumber();
System.out.println (lineNo + " " + line1);
//ta.setText(lineNo)
}
}
catch (IOException ioErr)
{
System.err.println (ioErr.toString());
System.exit(100);
}
}
if(e.getSource()==bt)
{
ag.dispose();
}

if(e.getSource() == b4)
{
dm.dispose();
}
if(e.getSource() == b3)
{
String a = (t1.getText());
String x = (t2.getText().toString());
int y = Integer.parseInt(t3.getText());
String d = t4.getText();
if(x.compareToIgnoreCase("bold") == 0)
{
f = new Font(a,Font.BOLD,y);
if(d.compareToIgnoreCase("red") == 0)
{
ta.setForeground(Color.red);
}
if(d.compareToIgnoreCase("magenta") == 0)
{
ta.setForeground(Color.magenta);
}
if(d.compareToIgnoreCase("pink") == 0)
{
ta.setForeground(Color.pink);
}
if(d.compareToIgnoreCase("blue") == 0)
{
ta.setForeground(Color.blue);
}
if(d.compareToIgnoreCase("orange") == 0)
{
ta.setForeground(Color.orange);
}
if(d.compareToIgnoreCase("cyan") == 0)
{
ta.setForeground(Color.cyan);
}
if(d.compareToIgnoreCase("yellow") == 0)
{
ta.setForeground(Color.yellow);
}
if(d.compareToIgnoreCase("green") == 0)
{
ta.setForeground(Color.green);
}
if(d.compareToIgnoreCase("gray") == 0)
{
ta.setForeground(Color.gray);
}
if(d.compareToIgnoreCase("black") == 0)
{
ta.setForeground(Color.black);
}
dm.dispose();
}
if(x.compareToIgnoreCase("italic") == 0)
{
f = new Font(a,Font.ITALIC,y);
if(d.compareToIgnoreCase("red") == 0)
{
ta.setForeground(Color.red);
}
if(d.compareToIgnoreCase("magenta") == 0)
{
ta.setForeground(Color.magenta);
}
if(d.compareToIgnoreCase("pink") == 0)
{
ta.setForeground(Color.pink);
}
if(d.compareToIgnoreCase("blue") == 0)
{
ta.setForeground(Color.blue);
}
if(d.compareToIgnoreCase("orange") == 0)
{
ta.setForeground(Color.orange);
}
if(d.compareToIgnoreCase("cyan") == 0)
{
ta.setForeground(Color.cyan);
}
if(d.compareToIgnoreCase("yellow") == 0)
{
ta.setForeground(Color.yellow);
}
if(d.compareToIgnoreCase("green") == 0)
{
ta.setForeground(Color.green);
}
if(d.compareToIgnoreCase("gray") == 0)
{
ta.setForeground(Color.gray);
}
if(d.compareToIgnoreCase("black") == 0)
{
ta.setForeground(Color.black);
}
dm.dispose();
}
if(x.compareToIgnoreCase("plain") == 0)
{
f = new Font(a,Font.PLAIN,y);
if(d.compareToIgnoreCase("red") == 0)
{
ta.setForeground(Color.red);
}
if(d.compareToIgnoreCase("magenta") == 0)
{
ta.setForeground(Color.magenta);
}
if(d.compareToIgnoreCase("pink") == 0)
{
ta.setForeground(Color.pink);
}
if(d.compareToIgnoreCase("blue") == 0)
{
ta.setForeground(Color.blue);
}
if(d.compareToIgnoreCase("orange") == 0)
{
ta.setForeground(Color.orange);
}
if(d.compareToIgnoreCase("cyan") == 0)
{
ta.setForeground(Color.cyan);
}
if(d.compareToIgnoreCase("yellow") == 0)
{
ta.setForeground(Color.yellow);
}
if(d.compareToIgnoreCase("green") == 0)
{
ta.setForeground(Color.green);
}
if(d.compareToIgnoreCase("gray") == 0)
{
ta.setForeground(Color.gray);
}
if(d.compareToIgnoreCase("black") == 0)
{
ta.setForeground(Color.black);
}
dm.dispose();
}

ta.setFont(f);
}

if(e.getSource() == find)
{
dd.setVisible(true);
dd.setSize(100,100);
dd.setBounds(100,100,100,100);
dd.pack();

}
if(e.getSource() == fb2)
{
dd.dispose();
}

}
public void keyPressed(KeyEvent s)
{}
public void keyReleased(KeyEvent s)
{}
public void keyTyped(KeyEvent s)
{
if(s.getSource() == b4)
{
dm.dispose();
}
if(s.getSource() == b3)
{

String a = (t1.getText());
String x = (t2.getText().toString());
int y = Integer.parseInt(t3.getText());
String d = t4.getText();
if(x.compareToIgnoreCase("bold") == 0)
{
f = new Font(a,Font.BOLD,y);
if(d.compareToIgnoreCase("red") == 0)
{
ta.setForeground(Color.red);
}
if(d.compareToIgnoreCase("magenta") == 0)
{
ta.setForeground(Color.magenta);
}
if(d.compareToIgnoreCase("pink") == 0)
{
ta.setForeground(Color.pink);
}
if(d.compareToIgnoreCase("blue") == 0)
{
ta.setForeground(Color.blue);
}
if(d.compareToIgnoreCase("orange") == 0)
{
ta.setForeground(Color.orange);
}
if(d.compareToIgnoreCase("cyan") == 0)
{
ta.setForeground(Color.cyan);
}
if(d.compareToIgnoreCase("yellow") == 0)
{
ta.setForeground(Color.yellow);
}
if(d.compareToIgnoreCase("green") == 0)
{
ta.setForeground(Color.green);
}
if(d.compareToIgnoreCase("gray") == 0)
{
ta.setForeground(Color.gray);
}
if(d.compareToIgnoreCase("black") == 0)
{
ta.setForeground(Color.black);
}
}
if(x.compareToIgnoreCase("italic") == 0)
{
f = new Font(a,Font.ITALIC,y);
if(d.compareToIgnoreCase("red") == 0)
{
ta.setForeground(Color.red);
}
if(d.compareToIgnoreCase("magenta") == 0)
{
ta.setForeground(Color.magenta);
}
if(d.compareToIgnoreCase("pink") == 0)
{
ta.setForeground(Color.pink);
}
if(d.compareToIgnoreCase("blue") == 0)
{
ta.setForeground(Color.blue);
}
if(d.compareToIgnoreCase("orange") == 0)
{
ta.setForeground(Color.orange);
}
if(d.compareToIgnoreCase("cyan") == 0)
{
ta.setForeground(Color.cyan);
}
if(d.compareToIgnoreCase("yellow") == 0)
{
ta.setForeground(Color.yellow);
}
if(d.compareToIgnoreCase("green") == 0)
{
ta.setForeground(Color.green);
}
if(d.compareToIgnoreCase("gray") == 0)
{
ta.setForeground(Color.gray);
}
if(d.compareToIgnoreCase("black") == 0)
{
ta.setForeground(Color.black);
}
}
if(x.compareToIgnoreCase("plain") == 0)
{
f = new Font(a,Font.PLAIN,y);
if(d.compareToIgnoreCase("red") == 0)
{
ta.setForeground(Color.red);
}
if(d.compareToIgnoreCase("magenta") == 0)
{
ta.setForeground(Color.magenta);
}
if(d.compareToIgnoreCase("pink") == 0)
{
ta.setForeground(Color.pink);
}
if(d.compareToIgnoreCase("blue") == 0)
{
ta.setForeground(Color.blue);
}
if(d.compareToIgnoreCase("orange") == 0)
{
ta.setForeground(Color.orange);
}
if(d.compareToIgnoreCase("cyan") == 0)
{
ta.setForeground(Color.cyan);
}
if(d.compareToIgnoreCase("yellow") == 0)
{
ta.setForeground(Color.yellow);
}
if(d.compareToIgnoreCase("green") == 0)
{
ta.setForeground(Color.green);
}
if(d.compareToIgnoreCase("gray") == 0)
{
ta.setForeground(Color.gray);
}
if(d.compareToIgnoreCase("black") == 0)
{
ta.setForeground(Color.black);
}
}
ta.setFont(f);
}
}
}

Comments

Popular Posts