Setting Undo/Redo menu text

When artwork is changed, the text for the Undo menu will be something like "Undo Move" or "Undo Color".  The AIUndo suite has a SetUndoText function that "Specifies the localizable text for Undo and Redo menu items".  However, when I use this function for my plugin, the text doesn't come out the way I would think.  When I pass in "Create" for the undo text, the menu will show up as "CreateUndo".  Ok, I can fix the spacing issue...  But it seems I should be able to set the entire string, not just half of it.  Or at least, the text I pass in should show up after 'Undo', not before it, to make it look like a normal Undo action.
Am I missing something, or does this just not work correctly?

It's not pretty, but here's the dump:
#ifdef WIN_ENV
#define CAPITAL_A_ANGSTROM        "\xC5"
#define SMALL_A_ANGSTROM        "\xE5"
#define A_ACCENT_UMLAUT            "\xE4"
#define E_ACCENT_AIGU            "\xE9"
#define O_ACCENT_AIGU            "\xF3"
#define O_ACCENT_UMLAUT            "\xF6"
#define U_ACCENT_UMLAUT            "\xFC"
#define NORWEIGIAN_O            "\xF8"
#define SMALL_LATIN_LIGATURE    "\xE6"
#define GERMAN_BETA                "\xDF"
#else
#define CAPITAL_A_ANGSTROM        "\x81"
#define SMALL_A_ANGSTROM        "\x8c"
#define A_ACCENT_UMLAUT            "\x8A"
#define E_ACCENT_AIGU            "\x8E"
#define O_ACCENT_AIGU            "\x97"
#define O_ACCENT_UMLAUT            "\x9A"
#define U_ACCENT_UMLAUT            "\x9F"
#define NORWEIGIAN_O            "\xBF"
#define SMALL_LATIN_LIGATURE    "\xBE"
#define GERMAN_BETA                "\xA7"
#endif
const char* UNDO_TEXT_TYPE_LOOKUP_TABLE[11][2] = {
        // English
        { "Undo", "Redo" },
        // Danish
        { "Fortryd", "Gentag" },
        // French
        { "Annuler", "R" E_ACCENT_AIGU "tablir" },
        // German
        { "R" U_ACCENT_UMLAUT "ckg" A_ACCENT_UMLAUT "ngig:", "Wiederherstellen:" },
        // Spanish
        { "Deshacer", "Rehacer" },
        // Finnish
        { "Peru", "Tee sittenkin" },
        // Italian
        { "Annulla", "Ripristina" },
        // Dutch
        { "Ongedaan maken", "Opnieuw" },
        // Norwegian
        { "Angre", "Gj" NORWEIGIAN_O "r om " },
        // Brazilian Portuguese
        { "Desfazer", "Refazer" },
        // Swedish
        { CAPITAL_A_ANGSTROM "ngra", "G" O_ACCENT_UMLAUT "r om" }

Similar Messages

  • Undo/redo menu doesn't work on runtime

    I am using a custom real-time menu. I have included the application
    functions of Undo and Redo as well as copy/cut/paste. The menu works
    fine when I run the vi in development mode; but when I build an exe
    using the application builder, undo and redo do not appear on the menu
    bar. The other menu items are there and work as expected.
    Does anyone know how to get around this problem? Any help is
    appreciated.
    muren

    I have the exact same problem. I am using LabVIEW 8.2, when I am in development mode the Undo/Redo work fine, if I build an executable the Undo/Redo options do not show. In the executable if I type ctrl+z, the control gets populated with zzz.
    I am not even doing a fancy menu. I am using the "minimal" menu option. 
    I am attaching a sample vi and the exe I did to show the problem.
    I hope someone can help and I don't have to wait 9 years. The previous post is from 2000!!!
    Thanks 
    Certified LabVIEW Architect * Certified Professional Instructor * LabVIEW Champion
    Attachments:
    temp-menu-test.vi ‏14 KB
    Menu-test.zip ‏26 KB

  • Can Undo & Redo text writing functions be set as icons?

    Undo & Redo are available as CTRL functions or from a menu but how do I set them up with an icon along with the other text editor icons?

    The Redo and Undo buttons are available with Toolbar Buttons, as part of the full add-on, or just those buttons.
    https://codefisher.org/toolbar_button/toolbar_button_maker/
    http://chrisramsden.vfast.co.uk/3_How_to_install_Add-ons_in_Thunderbird.html
    Right-click a Write window toolbar, Customize, and drag the buttons onto the toolbar.

  • How do you write UNDO for a text item?? examples? or a REDO??

    How do you write UNDO for a text item?? examples? or a REDO??
    I created a pop-up menu with CUT, COPY, PASTE, UNDO, CLEAR for my text items.
    Using MAGIC menu type works great but there is no MAGIC for UNDO or REDO.....
    How do you write UNDO for a text item?? examples? or a REDO??
    I have Oracle Forms 6i...
    Lets say I highlight all the text in the text item, and start typing over it... then I realize OH NO it is the wrong text field...
    Now I want to UNDO the typing and get back to the previous text.
    I'd use the initial value that was populate right? How do I access that if that is correct?
    Thanks, Bill

    You can use;
    <ITEM> := Get_Item_Property(<ITEM>,DATABASE_VALUE);
    Or you will have to write a pre-text-item trigger;
    PRE-TEXT-ITEM:
    :CTRL.CURRENT_VAL := :<BLOCK>.<ITEM>
    MENU (PL/SQL):
    :<BLOCK>.<ITEM> := :CTRL.CURRENT_VAL;
    You may also want to set the item property back to ITEM_IS_VALID so that item validation does not fire again.

  • Under System Preferences, Hardware, CD i DVD...  The menu text and dropdown choices are in a foreign Language.  I have my normal Language set to English.  What gives?

    Under System Preferences, Hardware, CD i DVD...  The menu text and dropdown choices are in a foreign Language.  I have my normal Language set to English.  What gives?

    Thanks for the reply. I only have English - Primary but I guess I could add Finland and then delete it...
    Okay, tried that, lots of variations including deleting all other languages and only using Finnish, and then using only British English etc - when guest is in Finnish the whole lot becomes Finnish/Suomi (see attached photos to compare with the ones above) - then when you delete Finnish and go back to English, everything is Englisg apart from 'Vierastilin käyttäjä' as above.
    Any other ideas where it stores that info - is there a dodgy preference file somewhere which needs zapping?

  • Keybindings for undo/redo buttons.

    I thought I knew how to do this, and I do seem to have this working fine for cut/copy/paste/select all keybindings CTRL X/C/V/A respectively.
    However I tried to do this for CTRL X and Y undo/redo and it's not working as I intended. Can anyone see what I'm doing wrong?
    I created a SSCCE based off the original example I was following from: [http://www.java2s.com/Code/Java/Swing-JFC/Undoredotextarea.htm]
    import java.awt.BorderLayout;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.KeyStroke;
    import javax.swing.event.UndoableEditEvent;
    import javax.swing.event.UndoableEditListener;
    import javax.swing.undo.CannotRedoException;
    import javax.swing.undo.UndoManager;
    public class UndoRedoTextArea extends JFrame implements KeyListener{
        private static final long serialVersionUID = 1L;
        protected JTextArea textArea = new JTextArea();
        protected UndoManager undoManager = new UndoManager();
        protected JButton undoButton = new JButton("Undo");
        protected JButton redoButton = new JButton("Redo");
        public UndoRedoTextArea() {
            super("Undo/Redo Demo");
            undoButton.setEnabled(false);
            redoButton.setEnabled(false);
            JPanel buttonPanel = new JPanel(new GridLayout());
            buttonPanel.add(undoButton);
            buttonPanel.add(redoButton);
            JScrollPane scroller = new JScrollPane(textArea);
            getContentPane().add(buttonPanel, BorderLayout.NORTH);
            getContentPane().add(scroller, BorderLayout.CENTER);
            textArea.getDocument().addUndoableEditListener(
                new UndoableEditListener() {
                    public void undoableEditHappened(UndoableEditEvent e) {
                        undoManager.addEdit(e.getEdit());
                        updateButtons();
            undoButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    try {
                        undoManager.undo();
                    } catch (CannotRedoException cre) {
                        cre.printStackTrace();
                    updateButtons();
            undoButton.addKeyListener(this);
            redoButton.addKeyListener(this);
            redoButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    try {
                        undoManager.redo();
                    } catch (CannotRedoException cre)  {
                        cre.printStackTrace();
                    updateButtons();
            setSize(400, 300);
            setVisible(true);
        public void updateButtons() {
            undoButton.setText(undoManager.getUndoPresentationName());
            redoButton.setText(undoManager.getRedoPresentationName());
            undoButton.setEnabled(undoManager.canUndo());
            redoButton.setEnabled(undoManager.canRedo());
        public static void main(String argv[]) {
            new UndoRedoTextArea();
        public void keyPressed(KeyEvent e){
            if (e.equals(KeyStroke.getKeyStroke
                (KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK))){
                // undo
                try {
                    undoManager.undo();
                } catch (CannotRedoException cre)  {
                    cre.printStackTrace();
                updateButtons();
            else if (e.equals(KeyStroke.getKeyStroke
                    (KeyEvent.VK_Y, InputEvent.CTRL_DOWN_MASK))){
                // redo
                try  {
                    undoManager.redo();
                } catch (CannotRedoException cre) {
                    cre.printStackTrace();
                updateButtons();
        public void keyTyped(KeyEvent e){}
        public void keyReleased(KeyEvent e){}
    }Edited by: G-Unit on Oct 24, 2010 5:30 AM

    camickr wrote:
    So the way I posted in the second lump of code OK (3rd post) or did you mean something different? Why did you set the key bindings? Did I not state they would be created automatically? I think you need to reread my suggestion (and the tutorial).Because I don't get it, it says only Menu items can contain accelerators and buttons only get mnemonics. I'm not using menu items here, I only have a text pane and 2 buttons. So I set the actions for the InputMap in TextPane. For the buttons, I pretty much used the small bit of code using undoManager.
    I tried to set KEYSTROKE constructor for the action and simply add them to the buttons that way, but this didn't seem to have any response.
    Also I don't get how this could happen anyway if the TextPane has the focus.
    Not like the example using MNEMONICS.
        Action leftAction = new LeftAction(); //LeftAction code is shown later
        button = new JButton(leftAction)
        menuItem = new JMenuItem(leftAction);
    To create an Action object, you generally create a subclass of AbstractAction and then instantiate it. In your subclass, you must implement the actionPerformed method to react appropriately when the action event occurs. Here's an example of creating and instantiating an AbstractAction subclass:
        leftAction = new LeftAction("Go left", anIcon,
                     "This is the left button.",
                     new Integer(KeyEvent.VK_L));
        class LeftAction extends AbstractAction {
            public LeftAction(String text, ImageIcon icon,
                              String desc, Integer mnemonic) {
                super(text, icon);
                putValue(SHORT_DESCRIPTION, desc);
                putValue(MNEMONIC_KEY, mnemonic);
            public void actionPerformed(ActionEvent e) {
                displayResult("Action for first button/menu item", e);
        }This is what I attempted. No errors... It just doesn't work.
    public JPanel p()
        undoButton.addActionListener(new UndoAction(KeyStroke.getKeyStroke(KeyEvent.VK_Z, Event.CTRL_MASK)));
        panel.add(undoButton);
        return panel;
    private class UndoAction extends AbstractAction
         public UndoAction(KeyStroke keyStroke)
              putValue(ACCELERATOR_KEY, keyStroke);
         private static final long serialVersionUID = 1L;
         public void actionPerformed(ActionEvent e)
              try
                   if (undoManager.canUndo())
                        undoManager.undo();
              catch (CannotRedoException cre)
                   cre.printStackTrace();
              updateButtons();
    }Edited by: G-Unit on Oct 25, 2010 8:32 AM

  • To many undo redo button

    Hi to everyone!!!
    I need your advice for my problem!!
    when I cliked new in the file to create a new JTextPane the undo redo button will multiply and if I have so many JTextPane then I have many undo redo in my toolbar
    here is my code.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    import java.util.*;
    import javax.swing.undo.*;
    public class URTest extends JFrame {
         JToolBar toolBar = new JToolBar();
         JButton undo;
         JButton redo = new JButton("Redo");
         JMenuBar menuBar = new JMenuBar();
         JMenu menu = new JMenu("File");
         JMenuItem item = new JMenuItem("New");
         JMenuItem item2 = new JMenuItem("Close");
         JTabbedPane tabbedPane = new JTabbedPane();
         JTextPane pane;
         public URTest() {
              item.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        create();
              item2.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        removeCreate();
              menu.add(item);
              menu.add(item2);
              menuBar.add(menu);
              this.add(toolBar,BorderLayout.NORTH);
              this.add(tabbedPane);
              this.setJMenuBar(menuBar);
         void create() {
              undo = new JButton("Undo");
              redo = new JButton("Redo");
              pane = new JTextPane();
              EditorKit editorKit = new StyledEditorKit() {
                   public Document createDefaultDocument() {
                        return new SyntaxDocument();
              pane.setEditorKit(editorKit);
              final CompoundUndoManager undoManager = new CompoundUndoManager( pane );
              undo.addActionListener( new ActionListener()
                   public void actionPerformed(ActionEvent e)
                        try
                             undoManager.undo();
                             pane.requestFocus();
                        catch (CannotUndoException ex)
                             System.out.println("Unable to undo: " + ex);
              redo.addActionListener( new ActionListener()
                   public void actionPerformed(ActionEvent e)
                        try
                             undoManager.redo();
                             pane.requestFocus();
                        catch (CannotRedoException ex)
                             System.out.println("Unable to redo: " + ex);
              toolBar.add(undo);
              toolBar.add(redo);
              tabbedPane.addTab("Tab",pane);
         void removeCreate() {
              tabbedPane.remove(tabbedPane.getSelectedIndex());
         public static void main(String[] args) {
              URTest frame = new URTest();
              frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              frame.setSize(400,400);
              frame.setVisible(true);
    class CompoundUndoManager extends UndoManager
         implements UndoableEditListener, DocumentListener
         public CompoundEdit compoundEdit;
         private JTextComponent editor;
         //  These fields are used to help determine whether the edit is an
         //  incremental edit. For each character added the offset and length
         //  should increase by 1 or decrease by 1 for each character removed.
         private int lastOffset;
         private int lastLength;
         public CompoundUndoManager(JTextComponent editor)
              this.editor = editor;
              editor.getDocument().addUndoableEditListener( this );
         **  Add a DocumentLister before the undo is done so we can position
         **  the Caret correctly as each edit is undone.
         public void undo()
              editor.getDocument().addDocumentListener( this );
              super.undo();
              editor.getDocument().removeDocumentListener( this );
         **  Add a DocumentLister before the redo is done so we can position
         **  the Caret correctly as each edit is redone.
         public void redo()
              editor.getDocument().addDocumentListener( this );
              super.redo();
              editor.getDocument().removeDocumentListener( this );
         **  Whenever an UndoableEdit happens the edit will either be absorbed
         **  by the current compound edit or a new compound edit will be started
         public void undoableEditHappened(UndoableEditEvent e)
              //  Start a new compound edit
              if (compoundEdit == null)
                   compoundEdit = startCompoundEdit( e.getEdit() );
                   lastLength = editor.getDocument().getLength();
                   return;
              //  Check for an attribute change
              AbstractDocument.DefaultDocumentEvent event =
                   (AbstractDocument.DefaultDocumentEvent)e.getEdit();
              if  (event.getType().equals(DocumentEvent.EventType.CHANGE))
                   compoundEdit.addEdit( e.getEdit() );
                   return;
              //  Check for an incremental edit or backspace.
              //  The change in Caret position and Document length should be either
              //  1 or -1 .
              int offsetChange = editor.getCaretPosition() - lastOffset;
              int lengthChange = editor.getDocument().getLength() - lastLength;
              if (Math.abs(offsetChange) == 1
              &&  Math.abs(lengthChange) == 1)
                   compoundEdit.addEdit( e.getEdit() );
                   lastOffset = editor.getCaretPosition();
                   lastLength = editor.getDocument().getLength();
                   return;
              //  Not incremental edit, end previous edit and start a new one
              compoundEdit.end();
              compoundEdit = startCompoundEdit( e.getEdit() );
         **  Each CompoundEdit will store a group of related incremental edits
         **  (ie. each character typed or backspaced is an incremental edit)
         private CompoundEdit startCompoundEdit(UndoableEdit anEdit)
              //  Track Caret and Document information of this compound edit
              lastOffset = editor.getCaretPosition();
              lastLength = editor.getDocument().getLength();
              //  The compound edit is used to store incremental edits
              compoundEdit = new MyCompoundEdit();
              compoundEdit.addEdit( anEdit );
              //  The compound edit is added to the UndoManager. All incremental
              //  edits stored in the compound edit will be undone/redone at once
              addEdit( compoundEdit );
              return compoundEdit;
         //  Implement DocumentListener
         //      Updates to the Document as a result of Undo/Redo will cause the
         //  Caret to be repositioned
         public void insertUpdate(final DocumentEvent e)
              SwingUtilities.invokeLater(new Runnable()
                   public void run()
                        int offset = e.getOffset() + e.getLength();
                        offset = Math.min(offset, editor.getDocument().getLength());
                        editor.setCaretPosition( offset );
         public void removeUpdate(DocumentEvent e)
              editor.setCaretPosition(e.getOffset());
         public void changedUpdate(DocumentEvent e)      {}
         class MyCompoundEdit extends CompoundEdit
              public boolean isInProgress()
                   //  in order for the canUndo() and canRedo() methods to work
                   //  assume that the compound edit is never in progress
                   return false;
              public void undo() throws CannotUndoException
                   //  End the edit so future edits don't get absorbed by this edit
                   if (compoundEdit != null)
                        compoundEdit.end();
                   super.undo();
                   //  Always start a new compound edit after an undo
                   compoundEdit = null;

    I was not actually sure what you wanted so I made the wild guess that you actually wanted only one pair of Undo/Redo buttons. Here you go :import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.util.List;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    import javax.swing.undo.*;
    public class URTest extends JPanel {
         private JMenuBar theMenuBar;
         private JTabbedPane theTabbedPane;
         private List<Pane> thePanes;
         private static class Pane {
              private JTextPane theTextPane;
              private CompoundUndoManager theUndoManager;
              private class CompoundUndoManager extends UndoManager implements UndoableEditListener, DocumentListener {
                   public CompoundEdit compoundEdit;
                   private int lastOffset;
                   private int lastLength;
                   public CompoundUndoManager() {
                        compoundEdit = null;
                   public void undo() {
                        theTextPane.getDocument().addDocumentListener(this);
                        super.undo();
                        theTextPane.getDocument().removeDocumentListener(this);
                   public void redo() {
                        theTextPane.getDocument().addDocumentListener(this);
                        super.redo();
                        theTextPane.getDocument().removeDocumentListener(this);
                   public void undoableEditHappened(UndoableEditEvent e) {
                        if (compoundEdit == null) {
                             compoundEdit = startCompoundEdit(e.getEdit());
                             lastLength = theTextPane.getDocument().getLength();
                             return;
                        AbstractDocument.DefaultDocumentEvent event = (AbstractDocument.DefaultDocumentEvent)e.getEdit();
                        if (event.getType().equals(DocumentEvent.EventType.CHANGE)) {
                             compoundEdit.addEdit(e.getEdit());
                             return;
                        int offsetChange = theTextPane.getCaretPosition() - lastOffset;
                        int lengthChange = theTextPane.getDocument().getLength() - lastLength;
                        if (Math.abs(offsetChange) == 1
                             && Math.abs(lengthChange) == 1) {
                             compoundEdit.addEdit(e.getEdit());
                             lastOffset = theTextPane.getCaretPosition();
                             lastLength = theTextPane.getDocument().getLength();
                             return;
                        compoundEdit.end();
                        compoundEdit = startCompoundEdit(e.getEdit());
                   private CompoundEdit startCompoundEdit(UndoableEdit anEdit) {
                        lastOffset = theTextPane.getCaretPosition();
                        lastLength = theTextPane.getDocument().getLength();
                        compoundEdit = new MyCompoundEdit();
                        compoundEdit.addEdit(anEdit);
                        addEdit(compoundEdit);
                        return compoundEdit;
                   public void insertUpdate(final DocumentEvent e) {
                        SwingUtilities.invokeLater(new Runnable() {
                             public void run() {
                                  int offset = e.getOffset() + e.getLength();
                                  offset = Math.min(offset, theTextPane.getDocument().getLength());
                                  theTextPane.setCaretPosition(offset);
                   public void removeUpdate(DocumentEvent e) {
                        theTextPane.setCaretPosition(e.getOffset());
                   public void changedUpdate(DocumentEvent e) {}
                   class MyCompoundEdit extends CompoundEdit {
                        public boolean isInProgress() {
                             return false;
                        public void undo() throws CannotUndoException {
                             if (compoundEdit != null) compoundEdit.end();
                             super.undo();
                             compoundEdit = null;
              public Pane() {
                   theTextPane = new JTextPane();
                   theTextPane.setEditorKit(new StyledEditorKit() {
                        public Document createDefaultDocument() {
                             return new SyntaxDocument();
                   theUndoManager = new CompoundUndoManager();
                   theTextPane.getDocument().addUndoableEditListener(theUndoManager);
              public JTextPane getTextPane() {
                   return theTextPane;
              public UndoManager getUndoManager() {
                   return theUndoManager;
         public URTest() {
              super(new BorderLayout(5, 5));
              setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
              JToolBar toolBar = new JToolBar();
              toolBar.setFloatable(false);
              toolBar.add(new AbstractAction("Undo") {
                   public void actionPerformed(ActionEvent e) {
                        undo();
              toolBar.add(new AbstractAction("Redo") {
                   public void actionPerformed(ActionEvent e) {
                        redo();
              add(toolBar, BorderLayout.NORTH);
              thePanes = new LinkedList<Pane>();
              theTabbedPane = new JTabbedPane();
              add(theTabbedPane, BorderLayout.CENTER);
              theMenuBar = new JMenuBar();
              JMenu menu = new JMenu("File");
              menu.add(new AbstractAction("New") {
                   public void actionPerformed(ActionEvent e) {
                        create();
              menu.add(new AbstractAction("Close") {
                   public void actionPerformed(ActionEvent e) {
                        remove();
              theMenuBar.add(menu);
         public JMenuBar getMenuBar() {
              return theMenuBar;
         private void create() {
              Pane pane = new Pane();
              thePanes.add(pane);
              theTabbedPane.addTab("Tab", pane.getTextPane());
         private void remove() {
              Pane selectedPane = getSelectedPane();
              if (selectedPane == null) return;
              thePanes.remove(selectedPane);
              theTabbedPane.remove(selectedPane.getTextPane());
         private void undo() {
              Pane selectedPane = getSelectedPane();
              if (selectedPane == null) return;
              try {
                   selectedPane.getUndoManager().undo();
                   selectedPane.getTextPane().requestFocus();
              } catch (CannotUndoException ex) {
                   System.out.println("Unable to undo: " + ex);
         private void redo() {
              Pane selectedPane = getSelectedPane();
              if (selectedPane == null) return;
              try {
                   selectedPane.getUndoManager().redo();
                   selectedPane.getTextPane().requestFocus();
              } catch (CannotRedoException ex) {
                   System.out.println("Unable to redo: " + ex);
         private Pane getSelectedPane() {
              Component selectedComponent = theTabbedPane.getSelectedComponent();
              if (selectedComponent == null) return null;
              for (Pane pane : thePanes) {
                   if (pane.getTextPane() == selectedComponent) return pane;
              return null;
         private static void test() {
              JFrame f = new JFrame("URTest");
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              URTest urTest = new URTest();
              f.setContentPane(urTest);
              f.setJMenuBar(urTest.getMenuBar());
              f.setSize(400, 400);
              f.setLocationRelativeTo(null);
              f.setVisible(true);
         public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        test();
    }Hope it helps.

  • Undo/Redo in JTextArea using UndoableEditListener

    I tried to implement undo/redo functionality in JTextArea using UndoableEditListener
    interface, but it throws java.lang.NullPointerException. I really not sure
    how the UndoableEditListener works?? I mean when the user type text in JTextArea,
    it already listens the event?? But when I go to menu bar and select "undo item,"
    how can they communicate??
    Here's my attempts. Thanks a lot!!
    private UndoManager undoManager;
    UndoableEditSupport edit = new UndoableEditSupport();
    //Registers an UndoableEditListener.
    edit.addUndoableEditListener(this);
    public void undoableEditHappened(UndoableEditEvent evt)
    {     undoManager = (UndoManager)evt.getEdit();
         //AbstractUndoableEdit edit = evt.getEdit();
    if (undoManager.canRedo())
         System.out.println("can redo...");
    if (undoManager.canUndo())
         System.out.println("can undo...");
    public void actionPerformed(ActionEvent evt)
    Object source = evt.getSource();
         if (source == undoItem)
              String s = undoManager.getUndoPresentationName();
              System.out.println("undo item = " + s);
    }

    Hi
    Sinceraly never used it in JTextArea components but since it also is an JTextComponent (as is JTextField) try to use this method:
        * add UNDO&REDO commands to a given textfield
      private void addUndoRedo(JTextField tf) {
        final UndoManager undo = new UndoManager();
        Document doc = tf.getDocument();
        doc.addUndoableEditListener(
          new UndoableEditListener() {
            public void undoableEditHappened(UndoableEditEvent evt) {
              undo.addEdit(evt.getEdit());
        tf.getActionMap().put(EDIT_CONTROLS[6][0], // UNDO
          new AbstractAction(EDIT_CONTROLS[6][0]) {
            public void actionPerformed(ActionEvent evt) {
              try {
                if (undo.canUndo()) { undo.undo(); }
              } catch (CannotUndoException e) {}
        tf.getInputMap().put(KeyStroke.getKeyStroke(EDIT_CONTROLS[6][1]), EDIT_CONTROLS[6][0]);
        tf.getActionMap().put(EDIT_CONTROLS[7][0], // REDO
          new AbstractAction(EDIT_CONTROLS[7][0]) {
            public void actionPerformed(ActionEvent evt) {
              try {
                if (undo.canRedo()) { undo.redo(); }
              } catch (CannotRedoException e) {}
        tf.getInputMap().put(KeyStroke.getKeyStroke(EDIT_CONTROLS[7][1]), EDIT_CONTROLS[7][0]);
      }I believe it'll work fine, please reply as possible.
    Regards.

  • How to reject Undo/Redo?

    We can receive notifies by using ' "AI Command Notifier: Before/After " + menu identifier text'.
    I intend to programming rejecting "Undo/Redo".
    I want to know how to describe for rejecting Undo/Redo commands.
    Best regards!

    As far as I know you can't 'reject' an Undo or Redo. That's simply not in our control.
    The closest you could do would be to call AIUndoSuite::PurgeAllUndos() but that will blow away all undos, so that's kind of overkill. Also, its deprecated, so who knows how long it will work.

  • New to undo/redo on component

    hello all,
    i'm new to swing programming & i have to develop a web enabled application. in that i'm having an internalframe which contains a panel with some labels in it. i'm able to move the labels around the panel by using mouse listener. but my problem is i have to implement undo/redo functionality on this movement. but i don't know how to proceed since i don't have a single idea abt this api. i got some materials related to undo/redo of textual components. but nothing related to this labels or components like that. can someone help me on this topic or guide me to some links which has details. if u can provide me some code samples i'll be really greateful.
    Thanks in advance

    The Java Tutorial provides a section on how to implement the java.swing.undo package.
    http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html#undo
    The TextComponentDemo example code it references uses a text Document to generate the UndoableEditListener events, but any component document or data model can be coded to do the same thing, such as the data model for your label placement panel. The listeners are usually added by a controlling parent class, such as a JFrame.
    * Create an addUndoableEditListener(UndoableEditListener listener) method in your model class.
    * Whenever an undoable edit is done in your model class, create an UndoableEditEvent object with the undoable edit data and call the undoableEditHappened(UndoableEditEvent e) method for all of your registered listeners.
    * Create an UndoManager object in your controlling parent class.
    * Create UndoAction and RedoAction subclassed objects in your controlling parent class.
    * Create an UndoableEditListener object in your controlling parent class and add it to your model class.
    The listeners will handle adding the UndoableEditEvent object to the UndoManager and updating any menu or toolbar Undo/Redo actions. The Undo/Redo actions will handle performing the commands via the UndoManager and updating the state of the Undo/Redo actions.
    I hope you find this of some help.

  • Photoshop CC 2014 UI Menu Text And Icon Size?

    so i really like that adobe has added the "experimental" option to increase the ui menu text and icon size in photoshop cc 2014, it was almost unreadable on my 2560 x 1440 27" monitor with photoshop cs4 and illustrator cs4, but the lone 200% setting is too big... seems that 125%, 150%, or maybe even 175% would be much better solutions. in fact, for reasons i can't quite understand, the ui text and icon size in illustrator cc 2014 is spot on, absolutely perfect on my monitor, even tho there is no option for increased ui size as far as i can tell, it was spot on the moment i installed and launched it.
    in short, the photoshop cs4 and illustrator cs4 user interfaces were identical in size as far as i could tell, and far too small on my 2560 x 1440 27" monitor. in terms of cc 2014, the illustrator ui is perfect out of the box on my monitor, considerably larger than illustrator cs4, while the photoshop cc 2014 ui is identical to cs4, tiny, but can be enlarged 200% which makes the ui too big. why couldn't/didn't adobe just make the photoshop cc 2014 base ui the exact same size as the illustrator cc 2014 ui? it would have been perfect (for my monitor size).

    thanks... just wish illustrator cc 2014 wasn't so perfect in terms of ui size, i mean it's just great and, consequently, makes it seem as if the ball was dropped with photoshop cc 2014... i mean how can one be spot on while the other be so far off?

  • Spry Menu Text only displays in hover color, doesn't sense browser edge

    I have a Spry horizontal menu in a website that is working fairly well in everything except IE6.  Firefox, Safari, and IE7 are all fine.
    In IE6, random menu items only display in the blue hover color, so they are invisible until you hover over them.
    My second problem is that the menu is right-aligned, and the button on the far right has three submenus.  I would like the second two submenus to automatically open to the left of the first submenu when opening to the right would cause them to be cut off by the edge of the browser window.  How do I do this??
    Here is my code (I've customized it with suggestions online, but just can't seem to fix the problem with IE6).
    Thanks for any help, I'm really stuck!!
    @charset "UTF-8";
    /* SpryMenuBarHorizontal.css - version 0.6 - Spry Pre-Release 1.6.1 */
    /* Copyright (c) 2006. Adobe Systems Incorporated. All rights reserved. */
    LAYOUT INFORMATION: describes box model, positioning, z-order
    /* The outermost container of the Menu Bar, an auto width box with no margin or padding */
    ul.MenuBarHorizontal
    margin: 0;
    padding: 0;
    list-style-type: none;
    font-size: 9pt;
    cursor: default;
    font-family: Helvetica, Arial, sans-serif;
    /* Set the active Menu Bar with this class, currently setting z-index to accomodate IE rendering bug: http://therealcrisp.xs4all.nl/meuk/IE-zindexbug.html */
    ul.MenuBarActive
    z-index: 1000;
    /* Menu item containers, position children relative to this container and are a fixed width */
    ul.MenuBarHorizontal li
    margin: 0;
    padding: 0;
    list-style-type: none;
    font-size: 100%;
    position: relative;
    text-align: left;
    cursor: pointer;
    width: auto;
    float: left;
    height: auto;
    /* Submenus should appear below their parent (top: 0) with a higher z-index, but they are initially off the left side of the screen (-1000em) */
    ul.MenuBarHorizontal ul
    margin: 0;
    padding: 0;
    list-style-type: none;
    font-size: 100%;
    z-index: 1020;
    cursor: default;
    width: 8.2em;
    position: absolute;
    left: -1000em;
    /* Submenu that is showing with class designation MenuBarSubmenuVisible, we set left to auto so it comes onto the screen below its parent menu item */
    ul.MenuBarHorizontal ul.MenuBarSubmenuVisible
    left: auto;
    /* Menu item containers are same fixed width as parent */
    ul.MenuBarHorizontal ul li
    width: 12em;
    /* Submenus should appear slightly overlapping to the right (95%) and up (-5%) */
    ul.MenuBarHorizontal ul ul
    position: absolute;
    margin: -5% 0 0 95%;
    /* Submenu that is showing with class designation MenuBarSubmenuVisible, we set left to 0 so it comes onto the screen */
    ul.MenuBarHorizontal ul.MenuBarSubmenuVisible ul.MenuBarSubmenuVisible
    left: auto;
    top: 0;
    DESIGN INFORMATION: describes color scheme, borders, fonts
    /* Submenu containers have borders on all sides */
    /*ul.MenuBarHorizontal ul
    border: 1px solid #CCC;
    /* Menu items are a blue block with padding and no text decoration */
    ul.MenuBarHorizontal a
    display: block;
    cursor: pointer;
    background-color: #0000ff;
    color: #fff180;
    text-decoration: none;
    li.MenuBarHorizontal a
    display: block;
    cursor: pointer;
    background-color: #0000FF;
    color: #FFF180;
    text-decoration: none;
    padding-top: 5px;
    padding-bottom: 5px;
    padding-left: 5px;
    padding-right: 5px;
    /* Menu items that have mouse over or focus have a yellow background and blue text */
    ul.MenuBarHorizontal a:hover, ul.MenuBarHorizontal a:focus
    background-color: #fff180;
    color: #0000ff;
    /* Menu items that are open with submenus are set to MenuBarItemHover with a blue background and white text */
    ul.MenuBarHorizontal a.MenuBarItemHover, ul.MenuBarHorizontal a.MenuBarItemSubmenuHover, ul.MenuBarHorizontal a.MenuBarSubmenuVisible
    background-color: #fff180;
    color: #0000FF;
    SUBMENU INDICATION: styles if there is a submenu under a given menu item
    /* Menu items that have a submenu have the class designation MenuBarItemSubmenu and are set to use a background image positioned on the far left (95%) and centered vertically (50%) */
    ul.MenuBarHorizontal a.MenuBarItemSubmenu
    background-image: url(SpryMenuBarDown.gif);
    background-repeat: no-repeat;
    background-position: 95% 50%;
    /* Menu items that have a submenu have the class designation MenuBarItemSubmenu and are set to use a background image positioned on the far left (95%) and centered vertically (50%) */
    ul.MenuBarHorizontal ul a.MenuBarItemSubmenu
    background-image: url(SpryMenuBarRight.gif);
    background-repeat: no-repeat;
    background-position: 95% 50%;
    /* Menu items that are open with submenus have the class designation MenuBarItemSubmenuHover and are set to use a "hover" background image positioned on the far left (95%) and centered vertically (50%) */
    ul.MenuBarHorizontal a.MenuBarItemSubmenuHover
    background-image: url(SpryMenuBarDownHover.gif);
    background-repeat: no-repeat;
    background-position: 95% 50%;
    /* Menu items that are open with submenus have the class designation MenuBarItemSubmenuHover and are set to use a "hover" background image positioned on the far left (95%) and centered vertically (50%) */
    ul.MenuBarHorizontal ul a.MenuBarItemSubmenuHover
    background-image: url(SpryMenuBarRightHover.gif);
    background-repeat: no-repeat;
    background-position: 95% 50%;
    BROWSER HACKS: the hacks below should not be changed unless you are an expert
    /* HACK FOR IE: to make sure the sub menus show above form controls, we underlay each submenu with an iframe */
    ul.MenuBarHorizontal iframe
    position: absolute;
    z-index: 1010;
    filter:alpha(opacity:0.1);
    /* HACK FOR IE: to stabilize appearance of menu items; the slash in float is to keep IE 5.0 from parsing */
    @media screen, projection
    ul.MenuBarHorizontal li.MenuBarItemIE
    display: inline;
    f\loat: left;
    background: #FFF;
    @media screen {
    * html ul.MenuBarVertical ul {position: relative!important; float: left;
    margin: -10px -1000px -1000px 80px; display: inline;}
    * html ul.MenuBarVertical {position: static!important; }
    *:first-child+html ul.MenuBarVertical ul {position: relative!important;
    float: left; margin: -10px -1000px -1000px 80px;}
    *:first-child+html ul.MenuBarVertical {position: static!important; }

    If you want to see the website and menu in action, go to http://www.gwnetworks.com/playtri/index_new2.html
    Thanks again!

  • Lazy Notification and Command Undo/Redo

    I have a two-part CS3 plug-in (model and UI).<br /><br />When I click on one of the checkboxes in the UI, it causes a command to be executed that highlights certain fields in the document and sets a persistent boolean indicating the state of the higlighting.<br /><br />I want to be able to uncheck the checkbox when an Edit > Undo is done using lazy notification, but I've been working on this for a few days now and I can't get it to work.<br /><br />I've made the following changes to the model plug-in code:<br /><br />1. In the .fr file, I added this:<br />AddIn<br />{<br />     kDocWorkspaceBoss,<br />     kInvalidClass,<br />     {<br />          // Interface to the persistent prefs implementation<br />          IID_IVIPREFERENCES, kVIPrefsImpl,<br />               <br />          // Interface to the Toggle Highlighting command<br />          IID_IVIHIGHLIGHTCHANGE, kVISetHighlightDisplayedCmdImpl,<br />     }<br />},<br /><br />2. In the command's DoNotify method, I do a ModelChange call with an 'interestedIn' parameter of IID_IVIHIGHLIGHTCHANGE. I've tried invoking this method on various subjects, e.g., document subject, document workspace subject, document preferences subject (i.e., getting my persistent interface on the workspace and then getting an ISubject interface on it), all to no apparent avail.<br /><br />I've made the following changes to the UI plug-in code:<br /><br />1. In the .fr file, I added this:<br /><br />AddIn<br />{<br />     kDocWorkspaceBoss,<br />     kInvalidClass,<br />     {<br />          // Interface to the preference change observer<br />          IID_IPREFSOBSERVER, kVIPUIPrefsObserverImpl,<br />     }<br />},<br /><br />2. In the preference change observer's AutoAttach method, I do the following (with error checking removed here for clarity). I've tried various subjects besides the document workspace subject here as well...<br /><br />InterfacePtr<IActiveContext><br />    ac(gSession->GetActiveContext(), UseDefaultIID());<br />IDocument *doc = ac->GetContextDocument();<br />InterfacePtr<ISubject> subject(doc->GetDocWorkSpace(), UseDefaultIID());<br /><br />if (!subject->IsAttached(ISubject::kLazyAttachment, this,<br />    IID_IVIHIGHLIGHTCHANGE, IID_IPREFSOBSERVER)<br />) {<br />    subject->AttachObserver(ISubject::kLazyAttachment, this,<br />        IID_IVIHIGHLIGHTCHANGE, IID_IPREFSOBSERVER);<br />}<br /><br />I've implemented a LazyUpdate method in the preference change observer, but it never gets called -- not when the checkbox is checked, and not when an Undo or Redo is done. I've verified that the observer's AutoAttach method is getting called, and that the ModelChange method inside the command's DoNotify method is being called.<br /><br />Has anyone gotten lazy notification on command undo/redo to work? If so, can you tell me what I might be doing wrong?

    Don't post the same question repeatedly. I've removed the thread you started 4 days after this one with the identical same question.
    db

  • Undo/Redo Managers

    Hello again,
    is there any classes for undo/redo on a StyledDocument to be used with a JEditorPane? If yes, which one?
    Bernard

    Try reading this section from the Swing tutorial on "General Rules for Using Text Components" for demo code and explanations on Undo/Redo and other text features:
    http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html

  • Undo/Redo JTextPane for some events

    Hi,
    I have quite a concern. Right now I'm building an sort of an IDE for my university class. I have the coloring of the words and everything is going fine. However I want to add Undo/Redo operations for the JTextPane. Even though you can create the UndoManager to manage the undo and redo. It catches the coloring of the words that happens every 1 second.
    My question is how do I tell the undomanager that I only want to accept text as event for undo and redo and that it doesn't capture coloring as an undoable event.
    regards,
    Victor Pereira

    http://java-sl.com/tip_merge_undo_edits.html
    You can merge multiple undoable edits in one and join your text coloring events to real edits. See the link how to merge them.
    Regards,
    Stas

Maybe you are looking for

  • Running Dos Command using Java

    How do i run a particular Dos command using a simple java class?

  • Keyboard lag on imports

    Searched for this, but couldn't find anything. Anyone else experiencing keyboard lag when editing a document imported from MS Word 2007? Native Pages docs edit fine, no lag. But if I import a .doc or .docx file and edit it, there is extensive keyboar

  • Could not get Previous Week Day starting today

    I need help  to get PREVIOUS WEEK day starting today. Eg: Today is 15 / 09 / 2011 I need Date 08 / 09 / 2011 Hence both 15th and 08 are Thursday. One is today's thursday and other is previous week thursday. Regards

  • Launch Command Line Scanner with Runtime.exec()

    Hi im trying to develop all the process of a common Antivirus , I have a command line anti-virus. But when i try to scan a single file mi code doesnt work. I made the following code: Runtime runtime = Runtime.getRuntime(); commands = new String[] {"c

  • Flash and MAC OS

    Hi, I have another issue in FlashHelp. I have included a flash file inside a topic and I have generated the flashhelp output. The output is fine in Windows XP, but when I view the same in Mac OS, the flash file inside the topic is gets corrupted, i.e