Results 1 to 7 of 7
  1. #1
    realahmed8 is offline Member
    Join Date
    Jun 2008
    Posts
    13
    Rep Power
    0

    Default Help in building little text editor that perform the UNDO operation

    Can anyone please help me in building little application that perform only the undo operation, so the program is just text area and one button..
    when pressed last character deleted from text area..

    thank you..

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Sure, I'll help you if I can, but you'll need to post the code you have first. Best of luck.
    Last edited by Fubarable; 12-22-2008 at 04:35 AM.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Lol this is not a code bank, this is a forum where discussions take place. You must put an effort first of all. If you stuck on something post your full details question here.

    HINT: Read about Undo Manager.

  4. #4
    realahmed8 is offline Member
    Join Date
    Jun 2008
    Posts
    13
    Rep Power
    0

    Default

    well, i have used the undo manager to do it, but i need to build it from internal i.e. using Stack for example..

    Java Code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    import javax.swing.undo.*;
    import javax.swing.text.*; 
    import javax.swing.event.*; 
    
    public class UndoOp extends JFrame {
    
    private JTextPane t1;
    private UndoManager undo;
    
     public UndoOp() {
     
      super("Undo Operation");
    
      t1 = new JTextPane();
    
      undo = new UndoManager();
      Document doc = t1.getDocument();
      
      JPanel p1 = new JPanel();
      JPanel p2 = new JPanel();
     
      JButton b1 = new JButton("Undo");
      
    
      p1.setLayout(new GridLayout(1,1));
      p1.add(new JScrollPane(t1)); 
      p2.add(b1);
     
     
      this.getContentPane().add(p1, BorderLayout.CENTER);
      this.getContentPane().add(p2, BorderLayout.SOUTH);
    
       setSize(300, 200);
      show();
    
      doc.addUndoableEditListener(new UndoableEditListener() {
      public void undoableEditHappened(UndoableEditEvent evt) {
      undo.addEdit(evt.getEdit());
      }
      });
      
      b1.addActionListener(new ActionListener() { 
    
      public void actionPerformed(ActionEvent h) 
      { 
      try {
      if (undo.canUndo()) {
      undo.undo();
      }
      } 
      catch (CannotUndoException e) {
      }
      } 
      }); 
    
      }
    
      public static void main( String args[] )
       {
          UndoOp app = new UndoOp();
    
          app.addWindowListener(
             new WindowAdapter() {
               }
          );
       }
    }
    looking for help, thank you..

  5. #5
    einer08 is offline Member
    Join Date
    Apr 2009
    Posts
    1
    Rep Power
    0

    Default Need help... Need a text editor code

    Hello enyone.
    Im new in Java. I have to create a simply text editor in java with these menu bar:

    File:
    Edit:
    Cut, Copy, Paste
    Foramt:
    Font -> Times new Roman, Arial, Tahoma, Courier
    Size -> 12pt, 14pt, 16pt
    Bold
    Italic
    Colour -> Red, Blue, Black

    The file that savet by these text editor need to save to .txt

    Plese hellp me.
    Thnx.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    what in particular do you need help with?

  7. #7
    angryboy's Avatar
    angryboy is offline Senior Member
    Join Date
    Jan 2009
    Posts
    742
    Rep Power
    6

    Default

    einer08, please do not hijack someone's thread.
    USE CODE TAGS--> [CODE]...[/CODE]
    Get NotePad++ (free)

Similar Threads

  1. Drag out text editor pane
    By p4ndaman in forum Eclipse
    Replies: 3
    Last Post: 07-21-2008, 05:19 PM
  2. SWT Text Editor Demo
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-11-2008, 05:35 PM
  3. SWT Text Editor
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-07-2008, 05:43 PM
  4. how to post a long text in an editor
    By bachtoutou in forum New To Java
    Replies: 3
    Last Post: 06-06-2008, 03:00 AM
  5. Problem in Text Editor
    By mustahsan4u in forum New To Java
    Replies: 2
    Last Post: 03-26-2008, 03:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •