answersLogoWhite

0

import java.awt.*;

import java.awt.event.*;

import java.awt.datatransfer.*;

import java.io.*;

public class Editor extends Frame

{

String filename;

TextArea tx;

Clipboard clip = getToolkit().getSystemClipboard();

Editor()

{

setLayout(new GridLayout(1,1));

tx = new TextArea();

add(tx);

MenuBar mb = new MenuBar();

Menu F = new Menu("file");

MenuItem n = new MenuItem("New");

MenuItem o = new MenuItem("Open");

MenuItem s = new MenuItem("Save");

MenuItem e = new MenuItem("Exit");

n.addActionListener(new New());

F.add(n);

o.addActionListener(new Open());

F.add(o);

s.addActionListener(new Save());

F.add(s);

e.addActionListener(new Exit());

F.add(e);

mb.add(F);

Menu E = new Menu("Edit");

MenuItem cut = new MenuItem("Cut");

MenuItem copy = new MenuItem("Copy");

MenuItem paste = new MenuItem("Paste");

cut.addActionListener(new Cut());

E.add(cut);

copy.addActionListener(new Copy());

E.add(copy);

paste.addActionListener(new Paste());

E.add(paste);

mb.add(E);

setMenuBar(mb);

mylistener mylist = new mylistener();

addWindowListener(mylist);

}

class mylistener extends WindowAdapter

{

public void windowClosing (WindowEvent e)

{

System.exit(0);

}

}

class New implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

tx.setText(" ");

setTitle(filename);

}

}

class Open implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

FileDialog fd = new FileDialog(Editor.this, "select File",FileDialog.LOAD);

fd.show();

if (fd.getFile()!=null)

{

filename = fd.getDirectory() + fd.getFile();

setTitle(filename);

ReadFile();

}

tx.requestFocus();

}

}

class Save implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

FileDialog fd = new FileDialog(Editor.this,"Save File",FileDialog.SAVE);

fd.show();

if (fd.getFile()!=null)

{

filename = fd.getDirectory() + fd.getFile();

setTitle(filename);

try

{

DataOutputStream d = new DataOutputStream(new FileOutputStream(filename));

String line = tx.getText();

BufferedReader br = new BufferedReader(new StringReader(line));

while((line = br.readLine())!=null)

{

d.writeBytes(line + "\r\n");

d.close();

}

}

catch(Exception ex)

{

System.out.println("File not found");

}

tx.requestFocus();

}

}

}

class Exit implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

System.exit(0);

}

}

void ReadFile()

{

BufferedReader d;

StringBuffer sb = new StringBuffer();

try

{

d = new BufferedReader(new FileReader(filename));

String line;

while((line=d.readLine())!=null)

sb.append(line + "\n");

tx.setText(sb.toString());

d.close();

}

catch(FileNotFoundException fe)

{

System.out.println("File not Found");

}

catch(IOException ioe){}

}

class Cut implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

String sel = tx.getSelectedText();

StringSelection ss = new StringSelection(sel);

clip.setContents(ss,ss);

tx.replaceRange(" ",tx.getSelectionStart(),tx.getSelectionEnd());

}

}

class Copy implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

String sel = tx.getSelectedText();

StringSelection clipString = new StringSelection(sel);

clip.setContents(clipString,clipString);

}

}

class Paste implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

Transferable cliptran = clip.getContents(Editor.this);

try

{

String sel = (String) cliptran.getTransferData(DataFlavor.stringFlavor);

tx.replaceRange(sel,tx.getSelectionStart(),tx.getSelectionEnd());

}

catch(Exception exc)

{

System.out.println("not string flavour");

}

}

}

public static void main(String args[])

{

Frame f = new Editor();

f.setSize(500,400);

f.setVisible(true);

f.show();

}

}

User Avatar

Wiki User

∙ 15y ago
User Avatar

What else can I help you with?

Continue Learning about Engineering

What kind of file contain java source code?

'.java' files contain java source code. One can access these files on windows by using 'notepad'.


How many editor in which you can create java source code?

Java source code is a plain text file, so you can use practically any editor, for example NotePad (included in Windows) or better programs such as the freeware NotePad++. However, it is usually more convenient to use the editor included in an IDE that has support for Java.


What is Java editor?

A Java editor is nothing but a tool that can be used to edit java source files. Ex: Textpad, Notepad, Eclipse etc...


Why do you write your code in a Notepad file?

Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.


Where does source code come from in java?

Source code comes from the programmer...

Related Questions

What kind of file contain java source code?

'.java' files contain java source code. One can access these files on windows by using 'notepad'.


How many editor in which you can create java source code?

Java source code is a plain text file, so you can use practically any editor, for example NotePad (included in Windows) or better programs such as the freeware NotePad++. However, it is usually more convenient to use the editor included in an IDE that has support for Java.


What is Java editor?

A Java editor is nothing but a tool that can be used to edit java source files. Ex: Textpad, Notepad, Eclipse etc...


Why do you write your code in a Notepad file?

Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.Notepad is a text editor. What it saves is the source code of the programming language. Any source code is just a text file, so Notepad or any text editor can save a program's code.


Where does source code come from in java?

Source code comes from the programmer...


Is NotePad Plus Plus a compiler?

Notepad++ is a text editor, not a compiler. You can however, enter source code into Notepad++ and then compile it with a compiler such as GCC.


What does the Java compiler translate Java source code to?

The Java compiler translates Java source code to Java byte code.


Java source code for median filter algorithm?

research is going on to develop a source code for median filtering using java


How do you save a notepad file into a java file?

just add an extension .java when you save your notepad text file


Differencitate between source code and bytcode in java?

The source code is just the set of statements written in (any included) java language by a programer (in this case our source code is a text file with .java extension). And in other hand a bytecode is the resulting code of compile a .java file, It is not machine code, but it can be interpreted and executed by the jvm.


What does a compiler perform?

A compiler converts high-level source code into native machine. In the case of Java, source code is compiled to Java byte code suitable for interpretation by the Java virtual machine which produces the machine code.


Where does bytecode come from java?

It is created by the Java compiler, based on the source code (the .java file).

Trending Questions
.75 inch pipe 5 psi how much is water flow rate? How do hydraulic excavators work? Write a c plus plus program using queue operation? Which element is most suitable for giving a word or part of a sentence a special style? Research Triangle Park RTP is a publicprivate planned research park created in 1959 by leaders from business education and industry Which statement most accurately explains the benefits of RTP? Where is Y1 and common located on ac circuit board? What economical device - varistor - transistor etc can you use to supply power to a relay until the voltage drops to 10.5 volts? What is rotameter? Which component of an exposure control plan includes devices that isolate or remove the blood-borne pathogen hazard from the workplace? How did the nylon invention come about? What is the most significant technological innovation or scientific discovery of the last half of the twentieth century? Compare and contrast a circuit breaker and a fuse? What is the degree to which a substance resists flow known as? Replace two speed electric motor with single speed electric motor? What are the questions comes for visual basic 6.0 for the exam? What is the pitch of screw for bolt M12? A person who specializes in installation troubleshooting and repair of heating or air conditioning is called? What is the average salary of someone in HR? What is the minimum level of equipment that a program needs to run is referred to as? What are the ingredients of MC1-RC2 primer for asphalt?