Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners how to create notepad in java

Have Programming Question? Ask it here!
 
 
 


praphulla bhausaheb jadhav
how to create notepad in java
1 Answer(s)      a year ago
Posted in : Java Beginners


how to create notepad in java?


Advertisement
View Answers

July 31, 2013 at 1:58 PM


package NotePad;

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

public class NotepadExample extends JFrame implements ActionListener {
    private static final long serialVersionUID = 1L;
    private TextArea area = new TextArea("", 0, 0,
            TextArea.SCROLLBARS_VERTICAL_ONLY);
    private MenuBar menuBar = new MenuBar();
    private Menu file = new Menu();
    private MenuItem openFile = new MenuItem();
    private MenuItem newFile = new MenuItem();
    private MenuItem saveFile = new MenuItem();
    private MenuItem close = new MenuItem();

    public NotepadExample() {
        this.setSize(500, 300);
        this.setTitle("Java Notepad");
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.area.setFont(new Font("Century Gothic", Font.BOLD, 12));
        this.getContentPane().setLayout(new BorderLayout());
        this.getContentPane().add(area);
        this.setMenuBar(this.menuBar);
        this.menuBar.add(this.file);
        this.file.setLabel("File");
        this.openFile.setLabel("Open");
        this.openFile.addActionListener(this);
        this.openFile.setShortcut(new MenuShortcut(KeyEvent.VK_O, false));
        this.file.add(this.openFile);
        this.newFile.setLabel("NewFile");
        this.newFile.addActionListener(this);
        this.newFile.setShortcut(new MenuShortcut(KeyEvent.VK_O, false));
        this.file.add(this.newFile);
        this.saveFile.setLabel("Save");
        this.saveFile.addActionListener(this);
        this.saveFile.setShortcut(new MenuShortcut(KeyEvent.VK_S, false));
        this.file.add(this.saveFile);
        this.close.setLabel("Close");
        this.close.setShortcut(new MenuShortcut(KeyEvent.VK_F4, false));
        this.close.addActionListener(this);
        this.file.add(this.close);
    }

    public void actionPerformed(ActionEvent e) {

        if (e.getSource() == this.close)
            this.dispose();

        else if (e.getSource() == this.openFile) {
            JFileChooser open = new JFileChooser();
            int option = open.showOpenDialog(this);

            if (option == JFileChooser.APPROVE_OPTION) {
                this.area.setText("");
                try {

                    Scanner scan = new Scanner(new FileReader(open
                            .getSelectedFile().getPath()));
                    while (scan.hasNext())
                        this.area.append(scan.nextLine() + "\n");
                } catch (Exception ex) {

                    System.out.println(ex.getMessage());
                }
            }
        }

        else if (e.getSource() == this.saveFile) {
            JFileChooser save = new JFileChooser();
            int option = save.showSaveDialog(this);

            if (option == JFileChooser.APPROVE_OPTION) {
                try {

                    BufferedWriter out = new BufferedWriter(new FileWriter(save
                            .getSelectedFile().getPath()));
                    out.write(this.area.getText());
                    out.close();
                } catch (Exception ex) {

                    System.out.println(ex.getMessage());
                }
            }
        }
    }

    public static void main(String args[]) {
        NotepadExample app = new NotepadExample();
        app.setVisible(true);
    }
}

Thanks



Related Tutorials/Questions & Answers:
how to create notepad in java
how to create notepad in java  how to create notepad in java
How to create Notepad in Swing
How to create Notepad in Swing Program Description:- In this Example we have... or the string is null or empty. Example package NotePad; import java.awt.... javax.swing.*; public class Notepad extends JFrame { private static
Advertisements
Create your own Notepad in Java
Create your own Notepad in Java      ... programs. Now its turn to create notepad by own with the help of java language... full fleshed notepad application. So just go through the example and see how
notepad
notepad  i want java code for notepad
Opening Notepad
Opening Notepad  Sir/madam I want to open notepad from java...}; Runtime.getRuntime().exec(commands); }   Java Create... this. With Regards Vaishnavi Vishwanath   To open the notepad, just go through
How to create a class in java
How to create a class in java  I am a beginner in programming and tried to learn how to do programming in Java. Friends please explain how can I create a class in Java
How to Create Keyboard in JAVA
How to Create Keyboard in JAVA  please help me to create On-Screen Keyboard with java and please give me an another idia to make it ..............iam waiting for your help ,think u so much
How to create charts in Java?
How to create charts in Java?  Is there any example of creating charts and graphs in Java? thanks   Hi, check the tutorial: Chart & Graphs Tutorials in Java Thanks
how to create interfaces in java
how to create interfaces in java  HI, Here is my code public interface validateInfo { public void validate(String empcode, String password); } class updateInfo implements validateInfo { public void update() { //code
how to create reports in swing java?
how to create reports in swing java?  how to create reports in swing java
Expression Language execution in notepad
Expression Language execution in notepad  how to execute expression language in notepad for java i am using apache tomcat server4.0.
How to create first program in Java?
How to create first program in Java?  Hi, I am new in Java programming. Tell me How to create first program in Java? Thanks   Hi, Read more at First Java Program. Thanks
how to create executable - Java Beginners
how to create executable  How do i create a executable file from a java file thnks in adv...!  Hi Friend, Try the following code: import java.io.*; import java.util.jar.*; public class CreateExe { public
how create package of this java code
how create package of this java code  Hi,i have email code in java which is working fine with out making package but when i want to make package of this code its stop working.Its showing exception while I execute it.I have to use
how create package of this java code
how create package of this java code  Hi,i have email code in java which is working fine with out making package but when i want to make package of this code its stop working.Its showing exception while I execute it.I have to use
how to create exce sheet using java
how to create exce sheet using java  how to create excel sheet using java
how to create an excel file using java
how to create an excel file using java  how to create an excel file using java
how to create a header in jtable using java swing
how to create a header in jtable using java swing  how to create a header in jtable using java swing   d
how to create pdf file using java and itextjar
how to create pdf file using java and itextjar  How to create pdf file having paragraphs and alignments done using java and itextjar 5.10 version.? hope i get quick response
how to create pdf file using java and itextjar
how to create pdf file using java and itextjar  How to create pdf file having paragraphs and alignments done using java and itextjar 5.10 version.? hope i get quick response
how to create month wise serial number in java?
how to create month wise serial number in java?  Ex: For 1)January-serial number is 1/001,1/002,1/003 etc
How to Create Car Rental Application in Java ?
How to Create Car Rental Application in Java ?  Hi, How to Create a Car Renal Application using Java to Check the Car renting, booking... the car rental apps in Java
java how to create visual swing editor
java how to create visual swing editor   How do I create a visual swing designer in java ?Meaning that I can "draw" a button,a JTextArea from within my designer program . I just need some basics . I've got no idea how to start
how to create unit matrix in java of arbritary dimensions
how to create unit matrix in java of arbritary dimensions  i want to create the unit matrix of arbritary dimensions say (n*m).i m a new beginner to java.someone having the program for that? help would be appreciable
How to create new arraylist using Java
someone provides online example how to create new arraylist in java programming. thnaks,   Hi, In java programming language you can create new...How to create new arraylist using Java  hi, I want to develop
how to create this diamond structure with java. - Java Beginners
how to create this diamond structure with java.   * *** ***** * *** *** * ***** * *** *** * ***** * *** *** * ***** *** *   
how we can create website through java
how we can create website through java  Dear actually i wanna ask query about creation of website through java then how we can create web site through java plz help me..........i have already a web site ....specially for premium
how to create forum on java subject in jsp/servlet ?
how to create forum on java subject in jsp/servlet ?  hi , i want to implement forum on java subject in jsp/servlet technology .how can i do it,which is the table required for it in mysql? formate like what is java is ? 2Reply
how can create album in java by using Stack ....
how can create album in java by using Stack ....  hi all , if i press push button put the image to the stack , and when i press pop button remove the image ..??? please help me please
How to Create Circle In Java
How to Create Circle In Java     ..., you will learn how to create Circle Diagram. The java circle is the most..., you will also show that how to create square drawing. Inside the program define
How to run a Java program in CMD
discussed how to write and run Java program in CMD. Tips to run Java program... a notepad or any other editor and write a small program in Java as given below...! How to Program in Java What is Programming
How to create Runtime time jLabel in java swing ?
How to create Runtime time jLabel in java swing ?   hi sir. my problem is that i want to display database row on a jLabel. Suppose i retrived... will itself enter the number of Jlabel that will create on Panel. if user enter-3, ther
How to create LineDraw In Java
How to create LineDraw In Java     ... will learn how to create Line Drawing. This program  implements a line Drawing component. A java program explains the stroke line i.e. how to make thick
how to Create a media player - Java Beginners
how to Create a media player  hi great friends my name is David.please i need a source code with detailed explanation on how to create a media player mp3 format.I need this urgently please!my E-mail address
how can create a jar file - Java Beginners
how can create a jar file  plz any one help me which file can i create the jar file plz give exact command  Hi The basic format... that you want to create a JAR file. * The f option indicates that you want
If I open .class file with notepad what is displayed?
If I open .class file with notepad what is displayed?   What is displayed when we open java .class files with notepad
how can create clock baisc in java
how can create clock baisc in java   think u for help me ..   import java.awt.*; import java.util.*; import javax.swing.*; import java.awt.event.*; import javax.swing.event.*; public class DisplayClock extends JFrame
how can create clock baisc in java
how can create clock baisc in java   think u for help me ..   import java.awt.*; import java.util.*; import javax.swing.*; import java.awt.event.*; import javax.swing.event.*; public class DisplayClock extends JFrame
how can create clock baisc in java
how can create clock baisc in java   think u for help me ..   import java.awt.*; import java.util.*; import javax.swing.*; import java.awt.event.*; import javax.swing.event.*; public class DisplayClock extends JFrame
How to create a Java Runtime Editor - Swing AWT
How to create a Java Runtime Editor   Hi, I am working on a requirement in which I need to integrate a java runtime editor in swing application... using java swing, try the following code: import java.awt.BorderLayout
How to Create Text Area In Java
How to Create Text Area In Java       In this section, you will learn how to create Text Area in Java. This section provides you a complete code of the program for illustrating
we can create our own header file in java?n how to create?
we can create our own header file in java?n how to create?  we can create our own header file in java?n how to create
how to create menubar and the below background color/image in java swing
how to create menubar and the below background color/image in java swing  how to create menubar and the below background color/image in java swing
how to create a jar file for java classes? - Java Interview Questions
how to create a jar file for java classes?  I have 2 classes x1 and x2. packages names are com.bank.xyz; how to create a jar file for classes...://www.roseindia.net/tutorial/java/io/createJarFile.html Hope that it will be helpful
How to Create any type of Reports in Java - Java Beginners
How to Create any type of Reports in Java  Hello Sir ,How I can create any type of Reports like Crystal Reports etc(Student Result Report) in Java Application,plz Help Me Sir
How to create a duplicate buffer of a long buffer in java.
How to create a duplicate buffer of a long buffer in java. In this tutorial, we will see how to create a duplicate buffer that shares the content of long... C:\>java DuplicateBuffer Content in original long buffer
How to Create a ByteBuffer using Byte Array in java.
How to create a ByteBuffer using Byte Array in java.      ..., we will discuss how to creates a buffer using byte array. The ByteBuffer ...; The wrap method create a byte buffer by wrapping  the associated
How to create a read-only long buffer in java.
How to create a read-only long buffer in java. In this tutorial, we will see how to create a read-only long buffer that shares the content of another long...() The asReadOnlyBuffer() method create a new read-only buffer
How to Create CurveDraw In Java
How to Create CurveDraw In Java       Introduction In this section, you will learn how to create..., enables you to create a quadratic or cubic segment. Here, you will see
How do i create the node for target SMO in java..???
How do i create the node for target SMO in java..???  How do i create the node for target SMO in java..??? or else whats the method for accessing the target SMO
Advertisements
 

 

 

DMCA.com