JAVA NOTEPAD Action Perform like Work new file, save, saveAs etc
JAVA NOTEPAD
USING JAVA CREATING NOTEPAD
Level 2
File Edit
New Cut
Open Copy
Paste Paste
Save Select All
Save As
********************************************************************************
Using code you make a Notepad Application in your Laptop
This is The Level 2 Notepad application Wait for More
Preview of NOTEPAD Application
Using code you make a Notepad Application in your Laptop
-------------------------------------------------------------------------------------------------------------------------
package Listener;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class xFrame extends JFrame implements ActionListener
{
JMenuBar menuBar;
JMenu file,edit;
JMenuItem i1,i2,i3,i4,i5,i6,i7,i8;
JTextArea ta;
public xFrame()
{
Container c=getContentPane();
c.setLayout(null);
menuBar=new JMenuBar();
file=new JMenu("File");
edit=new JMenu("Edit");
i1=new JMenuItem("New");
i2=new JMenuItem("Open");
i3=new JMenuItem("Save");
i4=new JMenuItem("SaveAs");
i5=new JMenuItem("Cut");
i6=new JMenuItem("Copy");
i7=new JMenuItem("Paste");
i8=new JMenuItem("Select All");
i1.addActionListener(this);
i2.addActionListener(this);
i3.addActionListener(this);
i4.addActionListener(this);
i5.addActionListener(this);
i6.addActionListener(this);
i7.addActionListener(this);
i8.addActionListener(this);
file.add(i1);
file.add(i2);
file.add(i3);
file.add(i4);
edit.add(i5);
edit.add(i6);
edit.add(i7);
edit.add(i8);
menuBar.add(file);
menuBar.add(edit);
this.setJMenuBar(menuBar);
ta=new JTextArea();
ta.setBounds(10,10,370,370);
c.add(ta);
}
public void actionPerformed(ActionEvent e)
{
//// file menu
if(e.getSource()==i1)
{
ta.setText("new file..");
}
if(e.getSource()==i2)
{
ta.setText("Open..");
}
if(e.getSource()==i3)
{
ta.setText("Save..");
}
if(e.getSource()==i4)
{
ta.setText("Save as..");
}
/////edit menu
if(e.getSource()==i5)
{
ta.cut();
}
if(e.getSource()==i1)
{
ta.copy();
}
if(e.getSource()==i1)
{
ta.paste();
}
if(e.getSource()==i1)
{
ta.selectAll();
}
}
}
public class ActionEvent3
{
public static void main(String[] args)
{
xFrame f=new xFrame();
f.setTitle("Action Event ");
f.setBounds(100,100,400,400);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
}
Comments
Post a Comment