Elanthendral.M (HDCA)


                 11.Develop a programmer’s editor in java that supports
                     syntaxhighlighting, compilation support ,debugging
                                                          support,ect…


Aim :-
         To Develop a programmer’s editor in java that supports Syntax Highlighting ,
            compilation support , Debugging support.


Algorithm:-
I Syntax Highlighting
 1.1 Definition:-
     Definition
        Syntax highlighting is a feature of some text editors, that display text-
           especially Source code in different colors and fonts according to the
           category of terms.

  1.2 Introduction:-
   i.   This feature eases writing in a structured language such as a
        programming language or a markup language as both structures and
        syntax error are visually distinct.
  ii.   Highlighting does not affect the meaning of the text itself; it’s made only for
        human readers/editors
 iii.   Syntax highlighting is a form of secondary notation, since the highlights are
        not part of the text meaning, but serve to reinforce it. Some editor also integrate
        syntax highlighting with other features, such Highlighting with other features ,
        such as spell checking or code folding , as aids to editing which are
        external to the language.

   1.3 Procedure:-
   i.   Create a repository of sorts that would store all of the style changes that must
        be made to the document, and when the write lock is lifted , perform the
        changes. I’ve made the repository , and I’ve tried to make the changes just
        before painting the control , but that doesn’t work .Can anyone suggest a better
        time to perform the changes?
ii.    Start up a new thread that waits for the write lock to be lifted , and , when it is
         performs the changes . I’m not extremely familiar with threading in java ,
         through , so anyone who wants to give me a solution using this method need to
         be very explicit and verbose.
 iii.    Any other simple way that doesn’t involve using something other than
         JTextArea.




II Compilation
  2. 1 Definition:-
   i.    A compiler is a computer program (or set of programs) that transforms
         source code written in a programming language (the source language) into
         another computer language (the target language, often having a binary form
         known as object code). The most common reason for wanting to transform
         source code is to create an executable program
  ii.    Translate a (high level) language program into an equivalent assembly language
         program.

  2.2Java compilation
   i.    Source code java is compiled into “bytecode” instead of machine code.
  ii.    bytecode is executed by the virtual machine , it is device independent.
 iii.    Bytecode : assembly + types + object oriented layer.



  2.3 Introduction:-
  2.4Two main parts the compilation
   i.    To understand the program.
  ii.    To translate it into machine code.

        2.4.1 Understanding programs
           Procedure :-
            At the beginning a program is just a text:
                i.   Cut the sequence into words(lexical analysis)
               ii.   Organize words into sentences(syntactic analysis,parsing)
              iii.   Encodes the meaning of sentences

         Close to the understanding of natural languages , for natural language , start with a
flow of sounds
2.4.2 Generate machine programs
   Procedure :-
            i.   Produce machine code realizing the original program.
           ii.   Decompose complex abstract operations of the program into
                 sequences of simple , basic machine instruction.
          iii.   Optimize the program.


III Debugging :-

3. Definition:-
   A Degugger or Debugging tool is a computer program that is used to test and
          debug other programs (the “target” program ). The code to be examined
          might alternatively be running on an instruction set simulator(ISS), a
          technique that allows great power in its ability to halt when specific
          conditions are encountered but which will typically be somewhat slower
          than executing slower than executing the code directly on the appropriate
          (or the same). Some debugger offer two modes of operation – full or partial
          simulation , to limit this impact.


IV Tool Tips:-
     i.   Creating a tool tip for any Jcomponent object is easy .use the

                         Picture   Picture name     Tooltip name

                                     NEW            new.gif
                                     Open           open.gif
                                     Save           save.gif
                                     Copy           copy.gif
                                      Cut             cut.gif
                                      Past           past.gif
          setToolTipText method to set up a tool tip for the component .
    ii.   In this program we use the this type of the ToolTip;
V Task Manager
                In this project we use task manager


5.1 how to get the running applications in windows task manager using
java
    Why are you doing System type stuff using Java? It is not designed for it. If you
           want a command line command to get the "application" list that appears
           in TaskManager




5.2 What is task manager:-
  i.   Task Manager provides information about programs and processes running on
       your computer. It also displays the most commonly used performance measures
       for processes.
ii.          You can use Task Manager to monitor key indicators of your computer's
               performance. You can see the status of the programs that are running and end
               programs that have stopped responding. You can also assess the activity of
               running processes using as many as fifteen parameters, and see graphs and data
               on CPU and memory usage.
 iii.          In addition, if you are connected to a network, you can view network status and
               see how your network is functioning.
 iv.           If you have more than one user connected to your computer, you can see who is
               connected, what they are working on, and you can send them a message.




5.3 Programs that are running
   i.          The Applications tab shows the status of the programs running on your
               computer.
  ii.          On this tab, you can end, switch to, or start a program.

5.4 Processes that are running
  i.           The Processes tab shows information about the processes running on your
               computer.
 ii.           For example, you can display information on CPU and memory usage, page faults,
               handle count, and a number of other parameters.

5.5 Performance measures
        The Performance tab displays a dynamic overview of your computer's
              performance, including:

          i.      Graphs for CPU and memory usage.
         ii.      Totals for the number of handles, threads, and processes running on
                  your computer.
        iii.      Totals, in kilobytes, for physical, kernel, and commit memory.

5.6 Viewing Network performance
   i.          The Networking tab displays a graphical representation of network
               performance. It provides a simple, qualitative indicator that shows the status of
               the network(s) that are running on your computer. The Networking tab is
               displayed only if a network card is present.
  ii.          On this tab, you can view the quality and availability of your network
               connection, whether you are connected to one or more than one network.
5.7Monitoring Sessions
  i.   The Users tab displays users who can access this computer, and session status
       and names. Client Name specifies the name of the client computer using the
       session, if applicable. Session provides a name for you to use to perform such
       tasks as sending another user a message or connecting to another user’s session.
 ii.   The Users tab is displayed only if the computer you are working on has Fast User
       Switching enabled, and is a member of a workgroup or is a standalone computer.
       The Users tab is unavailable on computers that are members of a network domain.




Program :-

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


/**
 * This class demonstrates Debugging,Syntax HighLighting,Compling
 * @author E.Annal Sheeba Rani
 * @Version jdk1.6
 */


public class sw1 extends JFrame implements ActionListener,
KeyListener
{

       // A frame with text field and Label field

JToolBar tb = new JToolBar();

       // icf & b1 an array of values.

String icf[] =
{"new.gif","open.gif","save.gif","cut.gif","copy.gif","paste.gif"};
// b1 represents for Tooltip

String bl[] = {"New","Open","Save","Cut","Copy","Paste"};

     // Demonstrate a one-dimensional array

ImageIcon ic[] = new ImageIcon[icf.length];

     // use a lable to display syntax highlighting

Label l1 = new Label("Syntax Highlighting");
JButton mbl[] = new JButton[icf.length];

     // set up manu bar

MenuBar mbar = new MenuBar();
Menu a = new Menu("File");
Menu b = new Menu("Edit");
Menu c = new Menu("Font");
Menu d = new Menu("Font-Size");
Menu f = new Menu("System");
int fsize = 13;                                // assigns fsize the
Value 13
JTextArea ta,ta1;
JScrollPane js1;

// create a fontList using GraphicsEnvironment

String fontList[] =
GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFo
ntFamilyNames();

// create MenuItem

MenuItem m[] = new MenuItem[fontList.length];
MenuItem fs[] = new MenuItem[600];
MenuItem a1 = new MenuItem("New");
MenuItem a2 = new MenuItem("Open");
MenuItem a3 = new MenuItem("Save");
MenuItem a4 = new MenuItem("Save as");
MenuItem a5 = new MenuItem("-");
MenuItem a6 = new MenuItem("Exit");
MenuItem b1 = new MenuItem("Cut");
MenuItem b2 = new MenuItem("Copy");
MenuItem b3 = new MenuItem("Paste");
MenuItem d1 = new MenuItem("Compile");
MenuItem d2 = new MenuItem("Run");
String ck="";
int i;
public sw1()
{
       super("Java Editor");                  //set title
          setSize(1024,768);               //assign a layoutsize
           setLayout(null);
           ta=new JTextArea(10,10);
           js1=new JScrollPane(ta);
           ta1=new JTextArea(5,60);
           add(js1);add(ta);add(ta1);add(tb);
       a.add(a1);add(l1);
       a.add(a2);
       a.add(a3);
       a.add(a4);
       a.add(a5);
       a.add(a6);
       b.add(b1);
       b.add(b2);
       b.add(b3);

         f.add(d1);
         f.add(d2);

     mbar.add(a);
     mbar.add(b);
     mbar.add(c);
     mbar.add(d);
     mbar.add(f);
     setMenuBar(mbar);


// loop for FontList
for (i = 0; i < fontList.length; i++ )
 {
  m[i] = new MenuItem(fontList[i]);
  m[i].addActionListener(this);
  m[i].setActionCommand(""+i);
  c.add(m[i]);
  }


// loop for MenuItem


for (i = 8; i <=90 ; i+=2)
 {
  fs[i] = new MenuItem(String.valueOf(i));
  fs[i].addActionListener(new fs());
  d.add(fs[i]);
  }

//loop for ImageIcone


     for( i =0;i<bl.length;i++)
     {
     ic[i ]= new ImageIcon(icf[i]);

     mbl[i] = new JButton(ic[i]);

     mbl[i].setToolTipText(bl[i]);

           mbl[i].addActionListener(this);

     mbl[i].setActionCommand("z"+i);

     if(i==3) tb.addSeparator();
     tb.add(mbl[i]);
     }
           tb.reshape(0,0,500,35);
           ta.reshape(5,40,1005,500);
js1.reshape(5,4,100,35);



     // set foregroundcolor for l1 that is Syntax Highlighting

     l1.setForeground(Color.green);

     // set foregroundcolor for ta that is text area

    ta.setForeground(Color.blue);
    l1.reshape(400,550,130,30);
    ta1.reshape(5,600,1005,200);
    ta1.setForeground(Color.red);
add(tb);

     add(ta);
     add(js1);
     add(l1);

     // This Listener can performed in wh object

     a6.addWindowListener(new wh());


     // This Listener can be performed in this object


a1.addActionListener(this);
a2.addActionListener(this);
a3.addActionListener(this);
a4.addActionListener(this);

     // This Listener can be performed in wc object


a5.addActionListener(new wc());
b1.addActionListener(new wc());
b2.addActionListener(new wc());
b3.addActionListener(new wc());
d1.addActionListener(new wc());
d2.addActionListener(new wc());
     ta.addKeyListener(this);
     show();
}


//set button action


public class wh extends WindowAdapter {
  public void windowClosing(WindowEvent e) {
       System.exit(0);
}
}


           // an ActionListener that sets the FontSize


public class fs implements ActionListener {
 public void actionPerformed(ActionEvent e) {
fsize = Integer.parseInt(e.getActionCommand());
  System.out.println(fsize);
}}

public class wc implements ActionListener {
public void actionPerformed(ActionEvent e) {


           // create button actions

String cmd= e.getActionCommand();


           // associate actions with buttons


if (cmd.equals("Exit")) System.exit(0);
if (cmd.equals("Cut")) ta.cut();
if (cmd.equals("Copy")) ta.copy();
if (cmd.equals("Paste")) ta.paste();
if (cmd.equals("Save"))
{
}
if (cmd.equals("Compile"))
    {
   try {
Runtime rt= Runtime.getRuntime();
Process p= rt.exec("taskmgr.exe");
    }
 catch(Exception ea) {
  System.out.println("Error");
}
    }
     }
   }
 public void keyReleased(KeyEvent ke){}
 public void keyPressed(KeyEvent ke){}
 public void keyTyped(KeyEvent ke)
 {


     // create a KeyPressed , KeyReleased, Key Typed

 Character k = ke.getKeyChar();
 int mk = (int) k;
 System.out.println(mk);
 ck += k;

          // create KeyReleased action

 if (ck.equals("for "))
   {
   ta1.setText("");
   ta1.append("for(var=init;condition;incr/decr)n");
   ta1.append("{n");
   ta1.append(" set of statements;n");
   ta1.append("}n");
   ck="";
   }
if (ck.equals("if "))
  {
  ta1.setText("");
  ta1.append("if (condition)n");
  ta1.append("{n");
  ta1.append(" set of statements;n");
  ta1.append("}n");
  ta1.append("elsen");
  ta1.append("{n");
  ta1.append(" set of statements;n");
  ta1.append("}n");
  ck = "";
  }

if (ck.equals("do "))
  {
  ta1.setText("");
  ta1.append("don");
  ta1.append("{n");
  ta1.append(" set of statements;n");
  ta1.append("}n");
  ta1.append("while (condition);n");
  ck = "";
  }

if (ck.equals("while "))
  {
  ta1.setText("");
  ta1.append("while(condition)n");
  ta1.append("{n");
  ta1.append(" set of statements;n");
  ta1.append("}n");
  ck = "";
  }

 if (mk == 10 || mk == 32 || mk == 8 || mk == 9) ck ="";
}

          //to create Button Link
public void actionPerformed(ActionEvent ae)
{
 String s1 = (String) ae.getActionCommand();
int ck1=1;
 System.out.println(s1);

if (s1.equals("z0"))
 {
 ta.setText("");ck1=0;
 }

if (s1.equals("z3"))
 {
    ta.cut();ck1=0;
 }

if (s1.equals("z4"))
 {
    ta.copy();ck1=0;
 }


if (s1.equals("z5"))
 {
    ta.paste();ck1=0;
 }


if (s1.equals("z1"))
 {

// for open a file menu

   FileDialog fx = new FileDialog(this,"Open a File",FileDialog.LOAD);
   fx.setDirectory("d:jeditor");
   fx.setFile("*.*");
   fx.show();
   String mfname=fx.getDirectory()+fx.getFile();
   setTitle(mfname);
   File fx1=new File(mfname);
try
   {
       FileInputStream fis=new FileInputStream(fx1);
       int fsize=(int) fx1.length();
       byte d[] =new byte[fsize];
       fis.read(d);
       ta.setText("");
       ta.setText(new String(d));
    }
    catch(Exception ex){};
    ck1=0;
}


if (s1.equals("z2"))
 {

             // for open a save menu bar

 FileDialog f=new FileDialog(this,"Save a File",FileDialog.SAVE);
    f.setDirectory("d:jeditor");
    f.setFile("*.java");
    f.show();
    String fname=f.getDirectory()+f.getFile();
    setTitle(fname);
    File f1=new File(fname);
    try
    {
      FileOutputStream fos=new FileOutputStream(f1);
      String t=ta.getText();
      int fsize=t.length();
      byte[] d=new byte[fsize];
      t.getBytes(0,fsize,d,0);
      fos.write(d);
      fos.close();
    }
    catch(Exception e){};
    ck1=0;
}
if ((s1.compareTo("Open") != 0) && (s1.compareTo("Save")) != 0 &&
(s1.compareTo("New") != 0) && (s1.compareTo("Save as") != 0 &&
(ck1 == 1)))
  {
  int x = Integer.parseInt(ae.getActionCommand());
  String fname = fontList[x];
  Font f1 = new Font(fname,Font.BOLD,fsize);
  ta.setFont(f1);
 }


if (s1.equals("Open"))
{

     // for open a open menu bar

   FileDialog fx = new FileDialog(this,"Open a File",FileDialog.LOAD);
   fx.setDirectory("d:jeditor");
   fx.setFile("*.*");
   fx.show();
   String mfname=fx.getDirectory()+fx.getFile();
   setTitle(mfname);
   File fx1=new File(mfname);
try
   {
     FileInputStream fis=new FileInputStream(fx1);
     int fsize=(int) fx1.length();
     byte d[] =new byte[fsize];
     fis.read(d);
     ta.setText("");
     ta.setText(new String(d));
   }
   catch(Exception ex){};

}

if (s1.equals("New"))
{
 ta.setText("");
}
if (s1.equals("Save") || s1.equals("Save as"))
{

             // for open a save or saveas menu bar

    FileDialog f=new FileDialog(this,"Save a File",FileDialog.SAVE);
       f.setDirectory("d:jeditor");
       f.setFile("*.java");
       f.show();
       String fname=f.getDirectory()+f.getFile();
       setTitle(fname);
       File f1=new File(fname);
       try
       {
         FileOutputStream fos=new FileOutputStream(f1);
         String t=ta.getText();
         int fsize=t.length();
         byte[] d=new byte[fsize];
         t.getBytes(0,fsize,d,0);
         fos.write(d);
         fos.close();
       }
       catch(Exception e){};
}

}


public static void main(String args[])
{
  sw1 app = new sw1();
}
}
Out put:-
The output layout




The file menu out put:-

    In this file menu we can do the following performances. there are:-
                    i. Create a New file
                   ii. Open a file
iii.   Save a file
                      iv.    Save as a file
                       v.    Exit




Performances for the file menu:-
1: create a new file
     To create our new file , we can do following instruction

   1. On the File menu, click New.
   2. In the New Document task pane, under New, click From existing document.
   3. Click the document you want to create a new document from. If you want to open a
      document that was saved in a different folder, locate and open the folder.
   4. Click Create New.

      This document is created in the folder that contains the original document.


2. Open a file
      To open a file , we can do following instruction

   1. click File, and then click Open.
   2. In the Look in list, click the drive, folder, or Internet location that contains the file
      you want to open.
   3. In the folder list, locate and open the folder that contains the file.
   4. Click the file, and then click Open.
I.Save a file
  •   On the File menu, click Save.
  •   In the File name box, enter a new name for the file.
  •   Click Save.




Saveas a file
  1. On the File menu, click Save as.
  2. In the File name box, enter a new name for the file.
  3. Click the Save as type drop-down list, and then click the file format that you want
     the file saved in.



The out put for edit menu
                   The edit menu is also perform the following Idem
                          There are:-
                       i. Cut
                      ii. Copy
                     iii. Paste
II. Copy a file

   1. On the Standard toolbar, click Open             .
   2. Click a shortcut on the Places Bar, or in the Look in box, click the drive or folder
      that contains the file you want to copy.
   3. In the folder list, locate and open the folder that contains the file you want to copy.
   4. Right-click the file you want to copy, and then click Copy on the shortcut menu.
   5. In the Look in box, click the drive or folder you want to copy the file to.
   6. In the folder list, locate and open the folder you want to copy the file to.
   7. Right-click anywhere in the folder list (make sure your pointer is not resting over a file in
      the list), and then click Paste on the shortcut menu.

III.Cut and Paste a file

   1. On the Standard toolbar, click Open           .
   2. Click a shortcut on the Places Bar, or in the Look in box, click the drive or folder
      that contains the file you want to move.
   3. In the folder list, locate and open the folder that contains the file you want to move.
   4. Right-click the file you want to move, and then click Cut on the shortcut menu.
   5. In the Look in box, click the drive or folder you want to move the file to.
   6. In the folder list, locate and open the folder you want to move the file to.
   7. Right-click anywhere in the folder list (make sure your pointer is not resting over a
      file in the list), and then click Paste on the shortcut menu.


The output for syntaxhighlighting
    IF WE WANT THE OUTPUT FOR syntaxhighlighting WE FOLLOW THE
FOLLOWING COMMANDS:-
AT FIRST WE TYPE THE WORD ,FOR EXAMPLE WE WANT THE SYNTAX FOR ‘if’
              Type the if in text area
              Then pressed the spaces bar
              Then syntax can be apper in the syntaxhighligthing text.
The out put for system




 Procedure for compilation :-
    First write a program.
    Then click systemcompile.




                                   The Task Manager Dialog box can
                                    be opened.
                                   Then click filecompile.
 Task Manager dialog box can be apper.




 Then go to file menu in the Task Manager.
 Select NEW TASK(RUN…) ,then Run dialog box can be apper.




 Enter “cmd” and click ok button.
 Know we can run it.




 Thus we execute the program.

More Related Content

PDF
PDF
Java swing 1
DOC
F5 learning-area-5-programming
PPS
08 iec t1_s1_oo_ps_session_11
PPT
Big Java Chapter 1
PPS
01 iec t1_s1_oo_ps_session_01
DOCX
Notes of java first unit
PPTX
Rise of software
Java swing 1
F5 learning-area-5-programming
08 iec t1_s1_oo_ps_session_11
Big Java Chapter 1
01 iec t1_s1_oo_ps_session_01
Notes of java first unit
Rise of software

What's hot (20)

PDF
computer Unit 6
PPT
VB.Net GUI Unit_01
ZIP
Introduction to the Java(TM) Advanced Imaging API
PPS
04 iec t1_s1_oo_ps_session_05
DOC
Stnotes doc 5
DOC
PPS
09 iec t1_s1_oo_ps_session_13
DOCX
PROBLEM SOLVING
PDF
Java Programming Assignment
PPT
Ppt chapter01
PPS
01 gui 01
PPTX
Insight into progam execution ppt
PDF
Chapter 13.1.4
PDF
Object Oriented Programming -- Dr Robert Harle
PPS
Java session11
DOC
Richa garg itm
DOC
OBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTES
PPT
Overall 23 11_2007_hdp
PPT
Savitch ch 01
PPS
11 iec t1_s1_oo_ps_session_16
computer Unit 6
VB.Net GUI Unit_01
Introduction to the Java(TM) Advanced Imaging API
04 iec t1_s1_oo_ps_session_05
Stnotes doc 5
09 iec t1_s1_oo_ps_session_13
PROBLEM SOLVING
Java Programming Assignment
Ppt chapter01
01 gui 01
Insight into progam execution ppt
Chapter 13.1.4
Object Oriented Programming -- Dr Robert Harle
Java session11
Richa garg itm
OBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTES
Overall 23 11_2007_hdp
Savitch ch 01
11 iec t1_s1_oo_ps_session_16
Ad

Viewers also liked (9)

DOC
Autonomic computer
DOC
Autonomic computer
DOC
RTF
Ex3 lisp likelist in java
DOC
Packet filtering using jpcap
DOC
Image+processing
DOC
Routing security in ad hoc wireless network
PPT
Ad-HOc presentation
PDF
The Outcome Economy
Autonomic computer
Autonomic computer
Ex3 lisp likelist in java
Packet filtering using jpcap
Image+processing
Routing security in ad hoc wireless network
Ad-HOc presentation
The Outcome Economy
Ad

Similar to Ex11 mini project (20)

PDF
ArduinoWorkshop2.pdf
PPTX
THE BASIC TOOLS
PPT
PPT
APIs And SDKs Breaking Into And Succeeding In A Specialty Market
PPT
Computer Basics Final.ppt
PDF
system-software-tools
PPTX
Introduction to computer programming
PPT
Management information system software
PPTX
EMBEDDED SYSTEMS Lecture 4 IDE AND MICROCONTROLLERS.pptx
PDF
Intro to Software Engineering for non-IT Audience
PPT
программное обеспечение (по)
PPTX
CH2-Hardware and Software as level information technology.pptx
PPTX
programming for problem solving-1 unit -1 ppt.pptx
PDF
codeblocks-instructions.pdf
PDF
Computer and information technology lesson 1
PPT
COMPUTER PROGRAMMING
PDF
Chapter 01 Java Programming Basic Java IDE JAVA INTELLIEJ
PPTX
computer programming: an introduction.pptx
PPS
Power Point Lesson 04
PPTX
Ndu06 typesof language
ArduinoWorkshop2.pdf
THE BASIC TOOLS
APIs And SDKs Breaking Into And Succeeding In A Specialty Market
Computer Basics Final.ppt
system-software-tools
Introduction to computer programming
Management information system software
EMBEDDED SYSTEMS Lecture 4 IDE AND MICROCONTROLLERS.pptx
Intro to Software Engineering for non-IT Audience
программное обеспечение (по)
CH2-Hardware and Software as level information technology.pptx
programming for problem solving-1 unit -1 ppt.pptx
codeblocks-instructions.pdf
Computer and information technology lesson 1
COMPUTER PROGRAMMING
Chapter 01 Java Programming Basic Java IDE JAVA INTELLIEJ
computer programming: an introduction.pptx
Power Point Lesson 04
Ndu06 typesof language

Recently uploaded (20)

PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
PDF
My India Quiz Book_20210205121199924.pdf
PDF
Empowerment Technology for Senior High School Guide
PDF
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
PPTX
Virtual and Augmented Reality in Current Scenario
PPTX
Unit 4 Computer Architecture Multicore Processor.pptx
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PDF
Trump Administration's workforce development strategy
PPTX
Introduction to pro and eukaryotes and differences.pptx
PPTX
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
PDF
AI-driven educational solutions for real-life interventions in the Philippine...
PDF
Hazard Identification & Risk Assessment .pdf
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
B.Sc. DS Unit 2 Software Engineering.pptx
PDF
Complications of Minimal Access-Surgery.pdf
PDF
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
PDF
International_Financial_Reporting_Standa.pdf
PDF
advance database management system book.pdf
PPTX
Computer Architecture Input Output Memory.pptx
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
My India Quiz Book_20210205121199924.pdf
Empowerment Technology for Senior High School Guide
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
Virtual and Augmented Reality in Current Scenario
Unit 4 Computer Architecture Multicore Processor.pptx
Chinmaya Tiranga quiz Grand Finale.pdf
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Trump Administration's workforce development strategy
Introduction to pro and eukaryotes and differences.pptx
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
AI-driven educational solutions for real-life interventions in the Philippine...
Hazard Identification & Risk Assessment .pdf
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
B.Sc. DS Unit 2 Software Engineering.pptx
Complications of Minimal Access-Surgery.pdf
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
International_Financial_Reporting_Standa.pdf
advance database management system book.pdf
Computer Architecture Input Output Memory.pptx

Ex11 mini project

  • 1. Elanthendral.M (HDCA) 11.Develop a programmer’s editor in java that supports syntaxhighlighting, compilation support ,debugging support,ect… Aim :- To Develop a programmer’s editor in java that supports Syntax Highlighting , compilation support , Debugging support. Algorithm:- I Syntax Highlighting 1.1 Definition:- Definition Syntax highlighting is a feature of some text editors, that display text- especially Source code in different colors and fonts according to the category of terms. 1.2 Introduction:- i. This feature eases writing in a structured language such as a programming language or a markup language as both structures and syntax error are visually distinct. ii. Highlighting does not affect the meaning of the text itself; it’s made only for human readers/editors iii. Syntax highlighting is a form of secondary notation, since the highlights are not part of the text meaning, but serve to reinforce it. Some editor also integrate syntax highlighting with other features, such Highlighting with other features , such as spell checking or code folding , as aids to editing which are external to the language. 1.3 Procedure:- i. Create a repository of sorts that would store all of the style changes that must be made to the document, and when the write lock is lifted , perform the changes. I’ve made the repository , and I’ve tried to make the changes just before painting the control , but that doesn’t work .Can anyone suggest a better time to perform the changes?
  • 2. ii. Start up a new thread that waits for the write lock to be lifted , and , when it is performs the changes . I’m not extremely familiar with threading in java , through , so anyone who wants to give me a solution using this method need to be very explicit and verbose. iii. Any other simple way that doesn’t involve using something other than JTextArea. II Compilation 2. 1 Definition:- i. A compiler is a computer program (or set of programs) that transforms source code written in a programming language (the source language) into another computer language (the target language, often having a binary form known as object code). The most common reason for wanting to transform source code is to create an executable program ii. Translate a (high level) language program into an equivalent assembly language program. 2.2Java compilation i. Source code java is compiled into “bytecode” instead of machine code. ii. bytecode is executed by the virtual machine , it is device independent. iii. Bytecode : assembly + types + object oriented layer. 2.3 Introduction:- 2.4Two main parts the compilation i. To understand the program. ii. To translate it into machine code. 2.4.1 Understanding programs Procedure :- At the beginning a program is just a text: i. Cut the sequence into words(lexical analysis) ii. Organize words into sentences(syntactic analysis,parsing) iii. Encodes the meaning of sentences Close to the understanding of natural languages , for natural language , start with a flow of sounds
  • 3. 2.4.2 Generate machine programs Procedure :- i. Produce machine code realizing the original program. ii. Decompose complex abstract operations of the program into sequences of simple , basic machine instruction. iii. Optimize the program. III Debugging :- 3. Definition:- A Degugger or Debugging tool is a computer program that is used to test and debug other programs (the “target” program ). The code to be examined might alternatively be running on an instruction set simulator(ISS), a technique that allows great power in its ability to halt when specific conditions are encountered but which will typically be somewhat slower than executing slower than executing the code directly on the appropriate (or the same). Some debugger offer two modes of operation – full or partial simulation , to limit this impact. IV Tool Tips:- i. Creating a tool tip for any Jcomponent object is easy .use the Picture Picture name Tooltip name NEW new.gif Open open.gif Save save.gif Copy copy.gif Cut cut.gif Past past.gif setToolTipText method to set up a tool tip for the component . ii. In this program we use the this type of the ToolTip;
  • 4. V Task Manager In this project we use task manager 5.1 how to get the running applications in windows task manager using java Why are you doing System type stuff using Java? It is not designed for it. If you want a command line command to get the "application" list that appears in TaskManager 5.2 What is task manager:- i. Task Manager provides information about programs and processes running on your computer. It also displays the most commonly used performance measures for processes.
  • 5. ii. You can use Task Manager to monitor key indicators of your computer's performance. You can see the status of the programs that are running and end programs that have stopped responding. You can also assess the activity of running processes using as many as fifteen parameters, and see graphs and data on CPU and memory usage. iii. In addition, if you are connected to a network, you can view network status and see how your network is functioning. iv. If you have more than one user connected to your computer, you can see who is connected, what they are working on, and you can send them a message. 5.3 Programs that are running i. The Applications tab shows the status of the programs running on your computer. ii. On this tab, you can end, switch to, or start a program. 5.4 Processes that are running i. The Processes tab shows information about the processes running on your computer. ii. For example, you can display information on CPU and memory usage, page faults, handle count, and a number of other parameters. 5.5 Performance measures The Performance tab displays a dynamic overview of your computer's performance, including: i. Graphs for CPU and memory usage. ii. Totals for the number of handles, threads, and processes running on your computer. iii. Totals, in kilobytes, for physical, kernel, and commit memory. 5.6 Viewing Network performance i. The Networking tab displays a graphical representation of network performance. It provides a simple, qualitative indicator that shows the status of the network(s) that are running on your computer. The Networking tab is displayed only if a network card is present. ii. On this tab, you can view the quality and availability of your network connection, whether you are connected to one or more than one network.
  • 6. 5.7Monitoring Sessions i. The Users tab displays users who can access this computer, and session status and names. Client Name specifies the name of the client computer using the session, if applicable. Session provides a name for you to use to perform such tasks as sending another user a message or connecting to another user’s session. ii. The Users tab is displayed only if the computer you are working on has Fast User Switching enabled, and is a member of a workgroup or is a standalone computer. The Users tab is unavailable on computers that are members of a network domain. Program :- import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; /** * This class demonstrates Debugging,Syntax HighLighting,Compling * @author E.Annal Sheeba Rani * @Version jdk1.6 */ public class sw1 extends JFrame implements ActionListener, KeyListener { // A frame with text field and Label field JToolBar tb = new JToolBar(); // icf & b1 an array of values. String icf[] = {"new.gif","open.gif","save.gif","cut.gif","copy.gif","paste.gif"};
  • 7. // b1 represents for Tooltip String bl[] = {"New","Open","Save","Cut","Copy","Paste"}; // Demonstrate a one-dimensional array ImageIcon ic[] = new ImageIcon[icf.length]; // use a lable to display syntax highlighting Label l1 = new Label("Syntax Highlighting"); JButton mbl[] = new JButton[icf.length]; // set up manu bar MenuBar mbar = new MenuBar(); Menu a = new Menu("File"); Menu b = new Menu("Edit"); Menu c = new Menu("Font"); Menu d = new Menu("Font-Size"); Menu f = new Menu("System"); int fsize = 13; // assigns fsize the Value 13 JTextArea ta,ta1; JScrollPane js1; // create a fontList using GraphicsEnvironment String fontList[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFo ntFamilyNames(); // create MenuItem MenuItem m[] = new MenuItem[fontList.length]; MenuItem fs[] = new MenuItem[600]; MenuItem a1 = new MenuItem("New"); MenuItem a2 = new MenuItem("Open"); MenuItem a3 = new MenuItem("Save"); MenuItem a4 = new MenuItem("Save as");
  • 8. MenuItem a5 = new MenuItem("-"); MenuItem a6 = new MenuItem("Exit"); MenuItem b1 = new MenuItem("Cut"); MenuItem b2 = new MenuItem("Copy"); MenuItem b3 = new MenuItem("Paste"); MenuItem d1 = new MenuItem("Compile"); MenuItem d2 = new MenuItem("Run"); String ck=""; int i; public sw1() { super("Java Editor"); //set title setSize(1024,768); //assign a layoutsize setLayout(null); ta=new JTextArea(10,10); js1=new JScrollPane(ta); ta1=new JTextArea(5,60); add(js1);add(ta);add(ta1);add(tb); a.add(a1);add(l1); a.add(a2); a.add(a3); a.add(a4); a.add(a5); a.add(a6); b.add(b1); b.add(b2); b.add(b3); f.add(d1); f.add(d2); mbar.add(a); mbar.add(b); mbar.add(c); mbar.add(d); mbar.add(f); setMenuBar(mbar); // loop for FontList
  • 9. for (i = 0; i < fontList.length; i++ ) { m[i] = new MenuItem(fontList[i]); m[i].addActionListener(this); m[i].setActionCommand(""+i); c.add(m[i]); } // loop for MenuItem for (i = 8; i <=90 ; i+=2) { fs[i] = new MenuItem(String.valueOf(i)); fs[i].addActionListener(new fs()); d.add(fs[i]); } //loop for ImageIcone for( i =0;i<bl.length;i++) { ic[i ]= new ImageIcon(icf[i]); mbl[i] = new JButton(ic[i]); mbl[i].setToolTipText(bl[i]); mbl[i].addActionListener(this); mbl[i].setActionCommand("z"+i); if(i==3) tb.addSeparator(); tb.add(mbl[i]); } tb.reshape(0,0,500,35); ta.reshape(5,40,1005,500);
  • 10. js1.reshape(5,4,100,35); // set foregroundcolor for l1 that is Syntax Highlighting l1.setForeground(Color.green); // set foregroundcolor for ta that is text area ta.setForeground(Color.blue); l1.reshape(400,550,130,30); ta1.reshape(5,600,1005,200); ta1.setForeground(Color.red); add(tb); add(ta); add(js1); add(l1); // This Listener can performed in wh object a6.addWindowListener(new wh()); // This Listener can be performed in this object a1.addActionListener(this); a2.addActionListener(this); a3.addActionListener(this); a4.addActionListener(this); // This Listener can be performed in wc object a5.addActionListener(new wc()); b1.addActionListener(new wc()); b2.addActionListener(new wc()); b3.addActionListener(new wc()); d1.addActionListener(new wc());
  • 11. d2.addActionListener(new wc()); ta.addKeyListener(this); show(); } //set button action public class wh extends WindowAdapter { public void windowClosing(WindowEvent e) { System.exit(0); } } // an ActionListener that sets the FontSize public class fs implements ActionListener { public void actionPerformed(ActionEvent e) { fsize = Integer.parseInt(e.getActionCommand()); System.out.println(fsize); }} public class wc implements ActionListener { public void actionPerformed(ActionEvent e) { // create button actions String cmd= e.getActionCommand(); // associate actions with buttons if (cmd.equals("Exit")) System.exit(0); if (cmd.equals("Cut")) ta.cut(); if (cmd.equals("Copy")) ta.copy(); if (cmd.equals("Paste")) ta.paste();
  • 12. if (cmd.equals("Save")) { } if (cmd.equals("Compile")) { try { Runtime rt= Runtime.getRuntime(); Process p= rt.exec("taskmgr.exe"); } catch(Exception ea) { System.out.println("Error"); } } } } public void keyReleased(KeyEvent ke){} public void keyPressed(KeyEvent ke){} public void keyTyped(KeyEvent ke) { // create a KeyPressed , KeyReleased, Key Typed Character k = ke.getKeyChar(); int mk = (int) k; System.out.println(mk); ck += k; // create KeyReleased action if (ck.equals("for ")) { ta1.setText(""); ta1.append("for(var=init;condition;incr/decr)n"); ta1.append("{n"); ta1.append(" set of statements;n"); ta1.append("}n"); ck=""; }
  • 13. if (ck.equals("if ")) { ta1.setText(""); ta1.append("if (condition)n"); ta1.append("{n"); ta1.append(" set of statements;n"); ta1.append("}n"); ta1.append("elsen"); ta1.append("{n"); ta1.append(" set of statements;n"); ta1.append("}n"); ck = ""; } if (ck.equals("do ")) { ta1.setText(""); ta1.append("don"); ta1.append("{n"); ta1.append(" set of statements;n"); ta1.append("}n"); ta1.append("while (condition);n"); ck = ""; } if (ck.equals("while ")) { ta1.setText(""); ta1.append("while(condition)n"); ta1.append("{n"); ta1.append(" set of statements;n"); ta1.append("}n"); ck = ""; } if (mk == 10 || mk == 32 || mk == 8 || mk == 9) ck =""; } //to create Button Link
  • 14. public void actionPerformed(ActionEvent ae) { String s1 = (String) ae.getActionCommand(); int ck1=1; System.out.println(s1); if (s1.equals("z0")) { ta.setText("");ck1=0; } if (s1.equals("z3")) { ta.cut();ck1=0; } if (s1.equals("z4")) { ta.copy();ck1=0; } if (s1.equals("z5")) { ta.paste();ck1=0; } if (s1.equals("z1")) { // for open a file menu FileDialog fx = new FileDialog(this,"Open a File",FileDialog.LOAD); fx.setDirectory("d:jeditor"); fx.setFile("*.*"); fx.show(); String mfname=fx.getDirectory()+fx.getFile(); setTitle(mfname); File fx1=new File(mfname);
  • 15. try { FileInputStream fis=new FileInputStream(fx1); int fsize=(int) fx1.length(); byte d[] =new byte[fsize]; fis.read(d); ta.setText(""); ta.setText(new String(d)); } catch(Exception ex){}; ck1=0; } if (s1.equals("z2")) { // for open a save menu bar FileDialog f=new FileDialog(this,"Save a File",FileDialog.SAVE); f.setDirectory("d:jeditor"); f.setFile("*.java"); f.show(); String fname=f.getDirectory()+f.getFile(); setTitle(fname); File f1=new File(fname); try { FileOutputStream fos=new FileOutputStream(f1); String t=ta.getText(); int fsize=t.length(); byte[] d=new byte[fsize]; t.getBytes(0,fsize,d,0); fos.write(d); fos.close(); } catch(Exception e){}; ck1=0; }
  • 16. if ((s1.compareTo("Open") != 0) && (s1.compareTo("Save")) != 0 && (s1.compareTo("New") != 0) && (s1.compareTo("Save as") != 0 && (ck1 == 1))) { int x = Integer.parseInt(ae.getActionCommand()); String fname = fontList[x]; Font f1 = new Font(fname,Font.BOLD,fsize); ta.setFont(f1); } if (s1.equals("Open")) { // for open a open menu bar FileDialog fx = new FileDialog(this,"Open a File",FileDialog.LOAD); fx.setDirectory("d:jeditor"); fx.setFile("*.*"); fx.show(); String mfname=fx.getDirectory()+fx.getFile(); setTitle(mfname); File fx1=new File(mfname); try { FileInputStream fis=new FileInputStream(fx1); int fsize=(int) fx1.length(); byte d[] =new byte[fsize]; fis.read(d); ta.setText(""); ta.setText(new String(d)); } catch(Exception ex){}; } if (s1.equals("New")) { ta.setText(""); }
  • 17. if (s1.equals("Save") || s1.equals("Save as")) { // for open a save or saveas menu bar FileDialog f=new FileDialog(this,"Save a File",FileDialog.SAVE); f.setDirectory("d:jeditor"); f.setFile("*.java"); f.show(); String fname=f.getDirectory()+f.getFile(); setTitle(fname); File f1=new File(fname); try { FileOutputStream fos=new FileOutputStream(f1); String t=ta.getText(); int fsize=t.length(); byte[] d=new byte[fsize]; t.getBytes(0,fsize,d,0); fos.write(d); fos.close(); } catch(Exception e){}; } } public static void main(String args[]) { sw1 app = new sw1(); } }
  • 18. Out put:- The output layout The file menu out put:- In this file menu we can do the following performances. there are:- i. Create a New file ii. Open a file
  • 19. iii. Save a file iv. Save as a file v. Exit Performances for the file menu:- 1: create a new file To create our new file , we can do following instruction 1. On the File menu, click New. 2. In the New Document task pane, under New, click From existing document. 3. Click the document you want to create a new document from. If you want to open a document that was saved in a different folder, locate and open the folder. 4. Click Create New. This document is created in the folder that contains the original document. 2. Open a file To open a file , we can do following instruction 1. click File, and then click Open. 2. In the Look in list, click the drive, folder, or Internet location that contains the file you want to open. 3. In the folder list, locate and open the folder that contains the file. 4. Click the file, and then click Open.
  • 20. I.Save a file • On the File menu, click Save. • In the File name box, enter a new name for the file. • Click Save. Saveas a file 1. On the File menu, click Save as. 2. In the File name box, enter a new name for the file. 3. Click the Save as type drop-down list, and then click the file format that you want the file saved in. The out put for edit menu  The edit menu is also perform the following Idem There are:- i. Cut ii. Copy iii. Paste
  • 21. II. Copy a file 1. On the Standard toolbar, click Open . 2. Click a shortcut on the Places Bar, or in the Look in box, click the drive or folder that contains the file you want to copy. 3. In the folder list, locate and open the folder that contains the file you want to copy. 4. Right-click the file you want to copy, and then click Copy on the shortcut menu. 5. In the Look in box, click the drive or folder you want to copy the file to. 6. In the folder list, locate and open the folder you want to copy the file to. 7. Right-click anywhere in the folder list (make sure your pointer is not resting over a file in the list), and then click Paste on the shortcut menu. III.Cut and Paste a file 1. On the Standard toolbar, click Open . 2. Click a shortcut on the Places Bar, or in the Look in box, click the drive or folder that contains the file you want to move. 3. In the folder list, locate and open the folder that contains the file you want to move. 4. Right-click the file you want to move, and then click Cut on the shortcut menu. 5. In the Look in box, click the drive or folder you want to move the file to. 6. In the folder list, locate and open the folder you want to move the file to. 7. Right-click anywhere in the folder list (make sure your pointer is not resting over a file in the list), and then click Paste on the shortcut menu. The output for syntaxhighlighting IF WE WANT THE OUTPUT FOR syntaxhighlighting WE FOLLOW THE FOLLOWING COMMANDS:- AT FIRST WE TYPE THE WORD ,FOR EXAMPLE WE WANT THE SYNTAX FOR ‘if’  Type the if in text area  Then pressed the spaces bar  Then syntax can be apper in the syntaxhighligthing text.
  • 22. The out put for system Procedure for compilation :-  First write a program.  Then click systemcompile.  The Task Manager Dialog box can be opened.  Then click filecompile.
  • 23.  Task Manager dialog box can be apper.  Then go to file menu in the Task Manager.
  • 24.  Select NEW TASK(RUN…) ,then Run dialog box can be apper.  Enter “cmd” and click ok button.
  • 25.  Know we can run it.  Thus we execute the program.