Test Stand File menu item entry point execution in VC++ code

Hi,
Can you please suggest me, how to execute a file menu item entry point pragmatically in a VC++ code.
My process model seq inserts an item called "Select Model" into TS file menu.
i have to programmatically execute this entrypoint from an Operator interface developed in VC++.
Request your suggestion in this concern.

Couln't you just use the PerformClick Method?  So basically you'll have a reference to your menu somewhere in the code.  Get the node of the item you want and then use the PerformClick method.
From MSDN: http://msdn.microsoft.com/en-us/library/system.win​dows.forms.menuitem.performclick%28v=vs.71%29.aspx
I recommend that vs going through the TestStand API.  It will be a lot cleaner.
jigg
CTA, CLA
teststandhelp.com
~Will work for kudos and/or BBQ~

Similar Messages

  • "open recent file" menu item - 2 issues / aspects (Mac & Windows)

    regarding the  "open recent file" menu item in the File menu.
    1)   should have a way to "clear recent items".  Most software solves this by appending an item "Clear Recent Items" to the bottom of the list of aliases that springs forth from the menu.
    2) Further, in the preferences it should be able to be set to 0 to prevent the function entirely, not just natural #s 1-99.  This is the case in Windows Adobe REader, and on the Mac it was the case the last time I was able to check, but due to the bugs in 9.1.x regarding the ability to handle a case-sensitive file system I haven't been able to even open the preferences on the mac for a while.

    Michael:
    Thanks for your quick reply.
    Please note that this issue:  "open recent file" menu item that is not clearable, nor is the system preference able to be set to retain 0 files,
    has absolutely nothing to do with the file system issue.  It is just a design choice (or oversight or bug depending on your point of view).
    It is an issue of security/privacy to not have the Reader keep a list of recently viewed files, or to at least allow the user to clear the list.
    Thanks again for your time, interest, and speedy reply.
    Cheers!

  • How to customize or create new file menu items in Adobe Illustrator CS 6?

    Hi all,
    I have developed a script to perform some Custom action in Illustrator. I want to make this script run from a a File Menu Item so it can be invoked easily. Is there a way to customize Illustarator to add a new menu item or modify the existing menu tems functions. For example if the script needs to be invoked when the user click "Save" is there a way that could be done.
    Thanks

    Thanks Mark,
    When you mean by limited menu location does it mean a plugin could be added under "File" as options or AI only allows it under "Window" where you launch the plugins from normally.

  • Calling a Configuration Entry Point from a C# code module

    Hi,
    Is it possible to call a configuration entry point from a C# code module?
    I have a custom process model which creates some configuration entry points.
    One of the entry points, calls a C# method in a code module to display a Startup screen for the operator.
    In an Editor User Interface, I have added a toolbar, now I want to execute the previous entry point initiated from my C# code to get the Startup screen again when a button is clicked on the toolbar.
    Best regards

    Hi James,
    Thanks for your suggestion, but unfortunely the code hangs after executing the entrypoint, if have tried it in two ways, but both have the same result. Do you have any idea how to fix this.
    Trial 1:
      Engine engine = new Engine(); ApplicationMgr applicationMgr = (ApplicationMgr)engine.GetInternalOption(InternalOptions.InternalOption_ApplicationManager);EntryPoints entryPoints = applicationMgr.ConfigurationEntryPoints; int intIndex = 0;foreach (EntryPoint entryPoint in entryPoints) {    switch (entryPoint.Name.ToUpper())    {        case "TOGGLE ONLINE <-> OFFLINE":            object objEditArgs = System.Type.Missing;           entryPoint.Run(objEditArgs); // Application hangs after executing this command, the entrypoint does not execute!             break;        default:            break;     }
         intIndex++;
    Trial 2:
      Engine engine = new Engine(); ApplicationMgr applicationMgr = (ApplicationMgr)engine.GetInternalOption(InternalOptions.InternalOption_ApplicationManager);EntryPoints entryPoints = applicationMgr.ConfigurationEntryPoints; int intIndex = 0;foreach (EntryPoint entryPoint in entryPoints) {    switch (entryPoint.Name.ToUpper())    {
            case "TOGGLE ONLINE <-> OFFLINE":           // Application hangs after executing next command, the entrypoint does not execute!           applicationMgr.GetCommand(CommandKinds.CommandKind_ConfigurationEntryPoints_Set, intIndex).Execute(true);              break;        default:            break;     }
         intIndex++;
    Best regards

  • New Menu Item entry in Standard Help Menu

    Hi experts,
    I have added a custom menu item under the standard Help menu of SAP using SE41 (Menu Painter) with pragram name: MENUSYST and status: MEN
    I added the new entry and gave it a function code and activated the function code as well as the interface MENUSYST.
    This worked fine and the entry is visible at the desired location. Now on click of this new entry, I need to open a URL. I had a look at the HELP_START function module but modifying that to call the URL on click of the new menu item, would require an access key.
    Is there any other method available to accomplish the task?
    Regards,
    Reema.

    Hello,
    Basically I need to open a Custom Web Dynpro Application that I have created. Also I need to pass the trannsaction code as a parameter in the URL of the WDABAP Application.
    Pl help me proceed.
    Regards,
    Reema.

  • Help me in finding the entry points in the source code of java.....

    hi...
    I want to design a compilation server and apply some of the optimization technique's like inlining, SSA and others.
    So i require to find the entry points in source code from where i can include my code and check the performance of the program at level it is performing .
    Please help in this problem....
    and i also like to know what are hot methods in java context?

    BigDaddyLoveHandles wrote:
    Do you even know Java? Why not just let the HotSpot optimization do its thing?Good point, I would try either of two things.
    If you have a good understanding of Java internals and are confident you could optimise code better, I suggest you contribute to the OpenJDK and we can all benefit.
    Otherwise I suggest you try using the optimisation built into the compiler and the JVM.
    Note: the JVM optimises the code dramatically in ways most normal people won't have thought possible.
    The compiler doesn't optimise the code so much as it leaves this job to the JVM.
    Two examples;
    - say you call a small method often. The JVM can inline this method for you. (the same way a compiler would) However say this method can be over-ridden and later your program calls a different implementation, it can inline both methods even if the new method in a new class didn't exist when the first method was inlined.
    - In a 32-bit JVM, 32-bit registers and references are used. In a 64-bit JVM 64-bit registers and references are used without needing to recompile the code. However there is a third option of using 32-bit references in a 64-bit JVM. In this case, it assumes the bottom 3 bits are always 000 so it shifts the reference down 3 bits allowing you to access 32 GB using 32-bit references. Again, you can use this with libraries which were compiled before 64-bit JVMs were available.

  • File Menu Entry Point from VC

    Hi,
    I am trying to execute a File Menu entrypoint from VC++ code.
    can anyone please suggest how to do the same.
    I have used below piece of code in my project to execyte the entrypoint.
    Here, "Select Model" is one of the File menu item from my process model.
    i wanted to execute "Select Model" menu item from VC++ code. but the below piece of code is executing operation failed message
    I have doubt at my seqFile ptr. can you please suggest how to give process model seq file reference to seqFile ptr here.
            ExecutionPtr            newExecution = NULL;
            TS:equenceFilePtr        seqFile =GetSequenceFile()    ;
            TS:equenceFilePtr        processModel =     NULL;
            TS::EditArgsPtr            editArgs = NULL;
            TS::EditArgsPtr            seqArgs = NULL;
            _bstr_t                    entryPointName ="Select Model";
            TS::IEnginePtr engine = mApplicationMgr->GetEngine();
            processModel = engine->GetStationModelSequenceFile(NULL);
            editArgs = engine->NewEditArgs();
            editArgs->SetSelectedSequenceFile(seqFile);
            TS:ropertyObjectPtr container = engine->NewPropertyObject(PropValType_Container, FALSE, "", 0);
            container->SetValString("sequence", 0x1, "MainSequence");
            _variant_t vtEditArguments((LPDISPATCH)editArgs, TRUE);
            _variant_t vtSeqArguments((LPDISPATCH)container, TRUE);
            newExecution = engine->NewExecution(seqFile, entryPointName, processModel, 0,
                                                TS::ExecTypeMask_InitiallyHidden, vtSeqArguments, vtEditArguments, vtMissing);
            engine = NULL;
    SequenceFilePtr CTestExecDlg::GetSequenceFile(void)
        RuntimeTrace(" TRACE---------CTestExecDlg::GetSequenceFile(void)        \n");//trace
        return mFile;

    I'm assuming you have a process model configuration entry point placed in the File menu via a menu hint and that it works fine from the File menu. If so, the following code will execute it:
        long numInserted;
        TSUI::CommandsPtr commands = mApplicationMgr->NewCommands();
        commands->InsertKind(CommandKind_ConfigurationEntryPoints_Set, mSequenceFileViewMgr, -1, "File", "File, Edit, Execute, Debug, Configure, Tools, Help", &numInserted);
        commands->GetItem(0)->Execute(VARIANT_TRUE);

  • Test Stand seq w/ dll batch file execution not working

    I am using Test Stand 4.1, running a seq that calls a dll.  The dll contains a batch file execution function that has not been working properly.  I am not 100% sure what the function is as I do not have access to the direct code from which the dll was created.  I believe I have a file, however please remember this is a guess that I am looking at the correct function/file. 
    This is a Pass/Fail test step that calls a batch file.  The batch file runs properly without the use of Test Stand and called by the dll.  In the code that I believe is running, I see there is a step that I am guessing does not run (see below for test steps).  It seems as though these steps are being "stepped over" and not running, however the test does seem to be entering this function.  The test reports a pass/fail status as the data is reported into a txt file.  If the txt file contains the correct data, the test step reports PASS, even though the batchfile does not run.
    :Note:  [batchfile.bat] is the name of the batch file being called; the [ ] are not present 
    // Run Batch File
     ChkErr(LaunchExecutableEx([batchfile.bat] ,windowState,&handle));   
     // Wait for batch file to complete task
     do{
      ProcessSystemEvents();
     }while(!ExecutableHasTerminated (handle));
     RetireExecutableHandle (handle);
    Any one have any suggestions as to why the batch file is not being called and running properly?
    Thank you
    Jason_C

    Thanks for the feed back.  I have realized and it seems as though sometimes the CWD varies.  The current working directory when the batch file does not run seems to be set to the desktop, not to the specified directory.  The batch file is used to program a chip, calling the exe to run using commands.  The file are speciifed by an absolute path, however the exe is not.  The batch file is as below and seems to match up with a problem with the CWD.  How can change though?  I will have to check in the Start in field, but where can I find that property? 
     Thank You
    --Jason
    del ..\misc\mplab.txt
    echo C:\Program Files\JTRS\01_P55461U\bin\uutsw\CR1_T2V3L_PMM_STUB_LOAD.hex
    ..\misc\pm3cmd /5 /BLCC:\Program Files\JTRS\01_P55461U\misc\t2v3l_pmm_stub_load\t2v3l_pmm_stub_load.pm3 /k /m /y /e >> ..\misc\mplab.txt >> ..\misc\mplab.txt
    ..\misc\pm3cmd /5 /BVCC:\Program Files\JTRS\01_P55461U\misc\t2v3l_pmm_stub_load\t2v3l_pmm_stub_load.pm3 >> ..\misc\mplab.txt

  • GetCommand does not return my configuration entry points?

    If I'm in a client sequence file and I want to dynamically execute my own configuration entry point in the process model what is the best way to accomplish that?
    I am trying to get the application manager through an activex step using Engine.GetInternalOption(InternalOption_ApplicationmManager) and then I choose the GetCommand method with CommandKind_ConfigurationEntryPoints_Set.  It will only use an index for one of the 3 default configuration entry points (Report Options, Model Options or Database Options).  It throws an index out of range if I try to get my own.  This is from James Grey's post here: http://forums.ni.com/t5/NI-TestStand/Calling-a-Configuration-Entry-Point-from-a-C-code-module/td-p/1... (I'm not in .NET though.  I just want to use activex steps in TS).  The 3 default ones work perfectly.  It's only when I try my own that I've added.
    Any thoughts?
    jigg
    CTA, CLA
    teststandhelp.com
    ~Will work for kudos and/or BBQ~
    Solved!
    Go to Solution.

    I can call it directly as well but it doesn't exhibit the behavior I want.
    Basically we have a process model with a Configuration Entry point called About Test.  This calls a sub sequence which has 2 steps in it. The first step is a callback and the second is a VI call.  The VI displays a splash screen with our company logo, disclosure and the text (usually a software part number) returned by the callback.
    What I want to do is put the SequenceFileLoad callback in our clients and have a step in there that will invoke the About Test entry point upon sequence load.
    The series would look like this:
    SequenceFileLoad(client)>>About Test Configuration Entry Point(model)>>SubSequence(model)>>About Test Model Callback (client)>>VI Splash Screen(model)
    All of this would be a lot easier with a (ProcessModelFileLoad): http://forums.ni.com/t5/NI-TestStand-Idea-Exchange/ProcessModelFileLoad-Engine-Callback/idi-p/225016...
    So back to my point about it not working correctly.  It doesn't seem to be invoking the model callback when I use New Execution or call the sequence directly.
    Also, what is the explanation for my config entry points not showing up at all in the list?  it seems that function should grab all config entry points in the model..... 
    Thanks a bunch,
    jigg
    CTA, CLA
    teststandhelp.com
    ~Will work for kudos and/or BBQ~

  • Can't get menu items to be displayed

    Hello,
    The answer to my problem is probably quite simple but I can't see it and its driving me crazy, basically I can't get my menu items to be displayed like file, create and search. But what ever I add to the file menu items like open or save isn't displayed and I don't know why I think it may have to do with the action listeners but I'm not sure how or why or it could be because of where it is placed in the code, but again I'm not sure. Any help will be appreciated thanks!
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.GeneralPath;
    import java.awt.geom.*;
    import java.awt.image.*;
    class CharacterEditor2 extends JFrame implements ActionListener
      private Container pane;
      public JPanel sidebar = new JPanel();
    public JPanel library;
      public JPanel interface1 = new JPanel();
      private JPanel interface2 = new JPanel();
      public JPanel cards = new JPanel();
      public CardLayout layout = new CardLayout();
      public JButton headb = new JButton ("Head");
      public JButton bodyb = new JButton ("Body");
      private JButton legsb = new JButton ("Legs");
      private JButton handsb = new JButton ("Hands");
      private JButton freeHandb = new JButton ("Free Hand");
      private JButton eyesb = new JButton ("Eyes");
      private JButton mouthb = new JButton ("Mouth");
      private JButton earsb = new JButton ("Ears");
      private JButton noseb = new JButton ("Nose");
      private JButton hairb = new JButton ("Hair");
      public CharacterEditor2()
        addWindowListener(new WindowAdapter(){
          public void windowClosing(WindowEvent e){
            System.exit(0);}});
        pane = getContentPane();
        setTitle("JHH");
        library = new library();
        interface2.setBackground(Color.red);
        interface1.setBackground(Color.green);
        Panel p1 = new Panel();
        p1.setLayout(new GridLayout(2,0));
        sidebar.setLayout(new GridLayout(3,0));
        addButton(sidebar, headb);
        addButton(sidebar, bodyb);
        addButton(sidebar, legsb);
        addButton(sidebar, handsb);
        addButton(sidebar, freeHandb);
        addButton(sidebar, eyesb);
        addButton(sidebar, mouthb);
        addButton(sidebar, earsb);
        addButton(sidebar, noseb);
        addButton(sidebar, hairb);
        JMenuBar menuBar = new JMenuBar();
        this.setJMenuBar(menuBar);
        JMenu fileMenu = new JMenu("File");
        menuBar.add(fileMenu);
        JMenuItem openMI = new JMenuItem("Open");
        openMI.addActionListener(this);
        fileMenu.add(openMI);
        JMenuItem saveMI = new JMenuItem("Save");
        saveMI.addActionListener(this);
        fileMenu.add(saveMI);
        JMenuItem closeMI = new JMenuItem("Close");
        closeMI.addActionListener(this);
        fileMenu.add(closeMI);
        fileMenu.addSeparator();
        JMenuItem exitMI = new JMenuItem("Exit");
        exitMI.addActionListener(this);
        fileMenu.add(exitMI);
        JMenu createMenu = new JMenu("Create");
        menuBar.add(createMenu);
        JMenuItem entryMI = new JMenuItem("Entry");
        entryMI.addActionListener(this);
        createMenu.add(entryMI);
        JMenu searchMenu = new JMenu("Search");
        menuBar.add(searchMenu);
        JMenuItem searchCharacterMI = new JMenuItem("Search by Character");
        searchCharacterMI.addActionListener(this);
        searchMenu.add(searchCharacterMI);
        JMenuItem searchBackgroundMI = new JMenuItem("Search by Background");
        searchBackgroundMI.addActionListener(this);
        searchMenu.add(searchBackgroundMI);
        JMenuItem searchMovieMI = new JMenuItem("Search by Movie.");
        searchMovieMI.addActionListener(this);
        searchMenu.add(searchMovieMI);
        p1.add(sidebar);
        p1.add(interface1);
        p1.add(interface2);
        p1.add(library);
       //add scroller to library
       JScrollPane scroller =
             new JScrollPane(library,    
                       JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                       JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
         scroller.setPreferredSize(new Dimension(100,100));
         p1.add(scroller, library);
        pane.add(p1, BorderLayout.CENTER);
      private void addButton (Container c, JButton b)
        b.addActionListener(this);
        c.add(b);
      public void actionPerformed(java.awt.event.ActionEvent evt)
    ((CardLayout)library.getLayout()).show(library, evt.getActionCommand());
      public static void main(String[] args)
        CharacterEditor2 window = new CharacterEditor2();
        window.setTitle("Character Editor");
        window.setSize(900, 700);
        window.setVisible(true);
    }

    It's because you are mixing Swing components and AWT components. The menu items are actually displayed, but they are hidden behind the panel with all the buttons. Things will work fine if you change the following line:
    Panel p1 = new Panel();  // This is an AWT panel. Use this instead:
    JPanel p1 = new JPanel();Read more about it here:
    http://java.sun.com/products/jfc/tsc/articles/mixing/

  • Custom menu items

    i just want to know where to put this code
    CoreMenutItems and CoreMenuItemRelationships resources are used to introduce menu items. Below is a sample code on how to get it done.
    *<@dynamicdata CoreMenuItems@>*
    id, label, linkType, linkData
    MY_SEARCH, My Custom Search, cgi, IdcService=CUSTOM_SEARCH_SERVICE
    *<@end@>*
    *<@dynamicdata CoreMenuItemRelationships@>*
    parentId, id, loadOrder
    MENU_A, MY_SEARCH, 30
    *<@end@>*
    plz

    In your component wizard, add an include resource file (or reuse an existing one) and lauch editor to manually edit the hda file (note: I think it'll work in most resource files, but have tested it in includes). Copy paste the above code in there and you should have a menu item. Good Luck,
    Fabian

  • New Entry Point in Cisco Interaction Manager

    I have created a new Entry Point in Cisco Interaction Manager for web chat. I used a new Queue and a new Script for the que script selector. I added a new ICM queue script for the chat, a new Dialed Number / Script Selector. When I test the new chat, the entry point works and shows the new entry point name in the CIM agent, but it still queues to the existing queue in ICM, not the new one. Anyone have any idea what I might have missed?
    Thanks - Keith                  

    Hey Lara, the emails are not getting queued because they are abnormally handled after success path of Queue to skill group.
    please add a wait node, after success path of queue to skill group. set time in wait node to max time you want emails to stay in queue. may be after this you can use another queue or send some label back to CIM, which matches to non IPTA group on CIM.
    the same is applicable for Chat as well.
    coming to the point at the subsequent chat not routing to the same agent, this one depends on max concurrent task you configure in CIM for Chat queue.
    there is config tab in each ICM integrated queue called "Concurrent task limit", this is the one deciding factor on how many concurrent task for each queue an agent can handle.
    please try and let me know if that works.
    regards
    Chintan

  • Help - I can't find the "File" menu when I open iTunes

    I am trying to transfer a music file from my Mac to iTunes.  Directions state to click on the "File" menu when you open iTunes - but, seriously, I can't find a "File" menu item.  Help - I am tech challenged.  Thanks.

    You might need to bring up the menu bar to see the File menu.
    If you're using a version 11.0.x, click on the wee boxy icon up in the top-left corner of your iTunes to see the "Show Menu Bar" control, as per the following screenshot:

  • Mail photo browser will not open using button or menu item

    I have a Air 13" and recently installed Mountain Lion. Now the photo browser window in mail (apple mail) will not appear. Not from teh photo browser button on compose email or the file menu item. It worked flawlessly before. Can't find anything online about this.
    Assistance is appreciated.
    TS

    Same issue on new MBPro having just installed Mountain Lion.

  • Adding icons to menu items

    Okay, I'm a newbie at Java. I have a problem that I'm trying to solve. I added icons to the File menu item, that was easy, but how do I add icons to the other menu items? They are DefaultEditorKit. actions (cut copy paste undo redo) I can't seem to change their names either.
    I'm also having problems with saving the changes I make in the text area.
    Here's the whole code.
    package components;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.HashMap;
    import java.io.*;
    import javax.swing.*;
    import javax.swing.AbstractButton;
    import javax.swing.text.*;
    import javax.swing.event.*;
    import javax.swing.undo.*;
    public class TextComponentDemo extends JFrame implements ActionListener {
        JTextPane textPane;
        AbstractDocument doc;
        JTextArea changeLog;
        JButton newButton, openButton, saveButton, undoButton, redoButton, /*cutButton, copyButton, pasteButton,*/ boldButton, italicButton, underlineButton;
        protected String newline = "\n";
        HashMap<Object, Action> actions;
         File fFile = new File("default.txt");
         JavaFilter fJavaFilter = new JavaFilter();
        protected UndoAction undoAction;
        protected RedoAction redoAction;
        protected UndoManager undo = new UndoManager();
        public TextComponentDemo() {
            super("Notepad v1.0");
            //Create the text pane and configure it.
            textPane = new JTextPane();
            textPane.setCaretPosition(0);
            textPane.setMargin(new Insets(5,5,5,5));
            StyledDocument styledDoc = textPane.getStyledDocument();
            if (styledDoc instanceof AbstractDocument) {
                doc = (AbstractDocument)styledDoc;
            } else {
                System.err.println("Text pane's document isn't an AbstractDocument!");
                System.exit(-1);
            JScrollPane scrollPane = new JScrollPane(textPane);
            scrollPane.setPreferredSize(new Dimension(600, 350));
            newButton = new JButton ("", createImageIcon("images/new.png"));
            newButton.setBackground(Color.white);
       //     newButton.setActionCommand("nou");       
       //     newButton.addActionListener(this);        
            openButton = new JButton("", createImageIcon("images/open.png"));
            openButton.setBackground(Color.white);
            openButton.setActionCommand("deschide");       
            openButton.addActionListener(this);
            saveButton = new JButton("", createImageIcon("images/save.png"));
            saveButton.setBackground(Color.white);
            saveButton.setActionCommand("salveaza");       
            saveButton.addActionListener(this);
            Action actionBold = new StyledEditorKit.BoldAction();
            actionBold.putValue(Action.NAME, "Bold");
            boldButton = new JButton(actionBold);
            boldButton.setBackground(Color.white);
            Action actionItalic = new StyledEditorKit.ItalicAction();
            actionItalic.putValue(Action.NAME, "Italic");
            italicButton = new JButton(actionItalic);
            italicButton.setBackground(Color.white);
            Action actionUnderline = new StyledEditorKit.UnderlineAction();
            actionUnderline.putValue(Action.NAME, "Underline");
            underlineButton = new JButton(actionUnderline);
            underlineButton.setBackground(Color.white);
              String[] fontStrings = { "Arial", "Arial Black", "Comic Sans MS", "Georgia", "Serif", "SansSerif", "Times New Roman", "Trebuchet MS", "Verdana" };
              JComboBox fontList = new JComboBox(fontStrings);
            fontList.setSelectedIndex(0);
            fontList.setBackground(Color.white);
            fontList.setActionCommand("font");
            fontList.addActionListener(this);
               String[] sizeStrings = { "12", "14", "16", "18", "20", "22", "24", "36", "48" };
              JComboBox sizeList = new JComboBox(sizeStrings);
            sizeList.setSelectedIndex(0);
            sizeList.setBackground(Color.white);
            sizeList.setActionCommand("size");
            sizeList.addActionListener(this);
            JPanel buttonPanel = new JPanel(); //use FlowLayout
              buttonPanel.add(newButton);
            buttonPanel.add(openButton);
            buttonPanel.add(saveButton);
         //   buttonPanel.add(cutButton);
         //   buttonPanel.add(copyButton);
         //   buttonPanel.add(pasteButton);
            buttonPanel.add(boldButton);
            buttonPanel.add(italicButton);
            buttonPanel.add(underlineButton);
            buttonPanel.add(fontList);
            buttonPanel.add(sizeList);
            getContentPane().add(buttonPanel, BorderLayout.PAGE_START);
             getContentPane().add(scrollPane, BorderLayout.CENTER);
            //Set up the menu bar.
            createActionTable(textPane);
            JMenu fileMenu = createFileMenu();
            JMenu editMenu = createEditMenu();
            JMenu fontMenu = createFontMenu();
            JMenu ajutorMenu = createAjutorMenu();
            JMenuBar mb = new JMenuBar();
            mb.add(fileMenu);
            mb.add(editMenu);
            mb.add(fontMenu);
            mb.add(ajutorMenu);
            setJMenuBar(mb);
            //Start watching for undoable edits and caret changes.
            doc.addUndoableEditListener(new MyUndoableEditListener());
           //This one listens for edits that can be undone.
        protected class MyUndoableEditListener
                        implements UndoableEditListener {
            public void undoableEditHappened(UndoableEditEvent e) {
                //Remember the edit and update the menus.
                undo.addEdit(e.getEdit());
                undoAction.updateUndoState();
                redoAction.updateRedoState();
    private ImageIcon createImageIcon (String fileName) {
          return new ImageIcon(fileName);
    protected JMenu createFileMenu() {
              JMenu menu = new JMenu("Fisier");
              menu.setMnemonic(KeyEvent.VK_F);
            JMenuItem menuItem;
            ImageIcon iconNou = new ImageIcon("images/new.png");
            menuItem = new JMenuItem("Nou", iconNou);
            menuItem.setMnemonic(KeyEvent.VK_N);
            menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
       //   menuItem.setActionCommand("nou");       
       //   menuItem.addActionListener(this);         
            menu.add(menuItem);
         menu.addSeparator();
              ImageIcon iconOpen = new ImageIcon("images/open.png");
              menuItem = new JMenuItem("Deschide", iconOpen);
            menuItem.setMnemonic(KeyEvent.VK_O);
            menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
              menuItem.setActionCommand("deschide");       
            menuItem.addActionListener(this);
              menu.add(menuItem);
              ImageIcon iconSave = new ImageIcon("images/save.png");
              menuItem = new JMenuItem("Salveaza", iconSave);
            menuItem.setMnemonic(KeyEvent.VK_S);
            menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
              menuItem.setActionCommand("deschide");       
            menuItem.addActionListener(this);
              menu.add(menuItem);          
         menu.addSeparator();     
              ImageIcon iconQuit = new ImageIcon("images/quit.png");
              menuItem = new JMenuItem("Iesire", iconQuit);
            menuItem.setMnemonic(KeyEvent.VK_Q);
            menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
              menuItem.setActionCommand("iesire");       
            menuItem.addActionListener(this);
              menu.add(menuItem);                    
              return menu;
         public void actionPerformed(ActionEvent e) {
             boolean status = false;
           /* if ("nou".equals(e.getActionCommand())) {
                 nou();
            if ("deschide".equals(e.getActionCommand())) {
                 status = openFile();
                   if(!status)
                        JOptionPane.showMessageDialog(
                             null,
                             "Eroare la deschiderea fisierului!", "Fisierul nu a putut fi deschis.",
                             JOptionPane.ERROR_MESSAGE
          /* if ("salveaza".equals(e.getActionCommand())) {
                 status = saveFile();
                   if(!status)
                        JOptionPane.showMessageDialog(
                             null,
                             "Eroare IO in salvarea fisierului!", "Fisierul nu a putut fi salvat.",
                             JOptionPane.ERROR_MESSAGE
            if ("iesire".equals(e.getActionCommand())) {
                 System.exit(-1);
            if ("font".equals(e.getActionCommand())) {
                 JComboBox cb = (JComboBox)e.getSource();
                 String fontName = (String)cb.getSelectedItem();
                 String t = new String(textPane.getSelectedText());
    //               t.setText("fontName");
    //             t.setFont(new java.awt.Font(fontName, 0, 12));
    //               StyledEditorKit.FontFamilyAction font = new StyledEditorKit.FontFamilyAction(fontName, fontName);
         boolean openFile() {
                JFileChooser fc = new JFileChooser();
                fc.setDialogTitle("Deschide Fisier");
                fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
                fc.setCurrentDirectory(new File ("."));
                fc.setFileFilter(fJavaFilter);
                int result = fc.showOpenDialog(this);
                if(result == JFileChooser.CANCEL_OPTION) {
                     return true;
                else if(result == JFileChooser.APPROVE_OPTION) {
                     fFile = fc.getSelectedFile();
                     String file_string = readFile(fFile);
                     if(file_string != null) {
                          textPane.setText(file_string);
                     else
                          return false;
                else {
                     return false;
                return true;                                         
            public String readFile (File file) {
              StringBuffer fileBuffer;
             String fileString=null;
             String line;   
             try {
                   FileReader in = new FileReader (file);
                    BufferedReader dis = new BufferedReader (in);
                    fileBuffer = new StringBuffer () ;
                   while ((line = dis.readLine ()) != null) {
                     fileBuffer.append (line + "\n");
                    in.close ();
                    fileString = fileBuffer.toString ();
                  catch  (IOException e ) {
                    return null;
             return fileString;
    /* boolean saveFile () {
         File file = null;
         JFileChooser fc = new JFileChooser ();
         fc.setCurrentDirectory (new File ("."));
         fc.setFileFilter (fJavaFilter);
         fc.setSelectedFile (fFile);
         int result = fc.showSaveDialog (this);
         if (result == JFileChooser.CANCEL_OPTION) {
             return true;
         } else if (result == JFileChooser.APPROVE_OPTION) {
             fFile = fc.getSelectedFile ();
             if (fFile.exists ()) {
                 int response = JOptionPane.showConfirmDialog (null,
                   "Overwrite existing file?","Confirm Overwrite",
                    JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.QUESTION_MESSAGE);
                 if (response == JOptionPane.CANCEL_OPTION) return false;
             return writeFile (fFile, textPane.getText ());
         } else {
           return false;
      protected JMenu createEditMenu() {
            JMenu menu = new JMenu("Editare");
            menu.setMnemonic(KeyEvent.VK_E);
            JMenuItem menuItem;
            undoAction=new UndoAction();
            menu.add(undoAction);   
            redoAction = new RedoAction();
            menu.add(redoAction);
            menu.addSeparator();
              menu.add(getActionByName(DefaultEditorKit.cutAction));       
            menu.add(getActionByName(DefaultEditorKit.copyAction));
            menu.add(getActionByName(DefaultEditorKit.pasteAction));
            menu.addSeparator();
            menu.add(getActionByName(DefaultEditorKit.selectAllAction));
            return menu;
        //Create the style menu.
        protected JMenu createFontMenu() {
            JMenu menu = new JMenu("Font");
            menu.setMnemonic(KeyEvent.VK_F);
            JMenu subMenu = new JMenu ("Stil ");
            Action action = new StyledEditorKit.BoldAction();
            action.putValue(Action.NAME, "Bold");
            subMenu.add(action);
            action = new StyledEditorKit.ItalicAction();
            action.putValue(Action.NAME, "Italic");
            subMenu.add(action);
            action = new StyledEditorKit.UnderlineAction();
            action.putValue(Action.NAME, "Underline");
            subMenu.add(action);
              menu.add(subMenu);
            menu.addSeparator();
            JMenu subMenu2 = new JMenu ("Marime ");
            subMenu2.add(new StyledEditorKit.FontSizeAction("12", 12));
            subMenu2.add(new StyledEditorKit.FontSizeAction("14", 14));
            subMenu2.add(new StyledEditorKit.FontSizeAction("16", 16));
            subMenu2.add(new StyledEditorKit.FontSizeAction("18", 18));
            subMenu2.add(new StyledEditorKit.FontSizeAction("20", 20));
            subMenu2.add(new StyledEditorKit.FontSizeAction("22", 22));
            subMenu2.add(new StyledEditorKit.FontSizeAction("24", 24));
            subMenu2.add(new StyledEditorKit.FontSizeAction("36", 36));
            subMenu2.add(new StyledEditorKit.FontSizeAction("48", 48));
            menu.add(subMenu2);
            menu.addSeparator();
            JMenu subMenu3 = new JMenu ("Familie ");
            subMenu3.add(new StyledEditorKit.FontFamilyAction("Arial", "Arial"));
            subMenu3.add(new StyledEditorKit.FontFamilyAction("Arial Black", "Arial Black"));
            subMenu3.add(new StyledEditorKit.FontFamilyAction("Comic Sans MS", "Comic Sans MS"));
            subMenu3.add(new StyledEditorKit.FontFamilyAction("Georgia", "Georgia"));
            subMenu3.add(new StyledEditorKit.FontFamilyAction("Serif", "Serif"));
            subMenu3.add(new StyledEditorKit.FontFamilyAction("SansSerif", "SansSerif"));
            subMenu3.add(new StyledEditorKit.FontFamilyAction("Times New Roman", "Times New Roman"));
            subMenu3.add(new StyledEditorKit.FontFamilyAction("Trebuchet MS", "Trebuchet MS"));
            subMenu3.add(new StyledEditorKit.FontFamilyAction("Verdana", "Verdana"));
            menu.add(subMenu3);
            menu.addSeparator();
            JMenu subMenu4 = new JMenu ("Culoare ");
            subMenu4.add(new StyledEditorKit.ForegroundAction("Rosu", Color.red));
            subMenu4.add(new StyledEditorKit.ForegroundAction("Verde", Color.green));
            subMenu4.add(new StyledEditorKit.ForegroundAction("Albastru", Color.blue));
            subMenu4.add(new StyledEditorKit.ForegroundAction("Galben", Color.yellow));
            subMenu4.add(new StyledEditorKit.ForegroundAction("Gri", Color.gray));
            subMenu4.add(new StyledEditorKit.ForegroundAction("Gri inchis", Color.darkGray));
            subMenu4.add(new StyledEditorKit.ForegroundAction("Negru", Color.black));
            menu.add(subMenu4);
            return menu;
        protected JMenu createAjutorMenu() {
             JMenu menu = new JMenu("Ajutor");
            menu.setMnemonic(KeyEvent.VK_J);
            return menu;
        private void createActionTable(JTextComponent textComponent) {
            actions = new HashMap<Object, Action>();
            Action[] actionsArray = textComponent.getActions();
            for (int i = 0; i < actionsArray.length; i++) {
                Action a = actionsArray;
    actions.put(a.getValue(Action.NAME), a);
    private Action getActionByName(String name) {
    return actions.get(name);
    class UndoAction extends AbstractAction {
    public UndoAction() {
    super("Undo");
    setEnabled(false);
    public void actionPerformed(ActionEvent e) {
    try {
    undo.undo();
    } catch (CannotUndoException ex) {
    System.out.println("Unable to undo: " + ex);
    ex.printStackTrace();
    updateUndoState();
    redoAction.updateRedoState();
    protected void updateUndoState() {
    if (undo.canUndo()) {
    setEnabled(true);
    putValue(Action.NAME, undo.getUndoPresentationName());
    } else {
    setEnabled(false);
    putValue(Action.NAME, "Undo");
    class RedoAction extends AbstractAction {
    public RedoAction() {
    super("Redo");
    setEnabled(false);
    public void actionPerformed(ActionEvent e) {
    try {
    undo.redo();
    } catch (CannotRedoException ex) {
    System.out.println("Unable to redo: " + ex);
    ex.printStackTrace();
    updateRedoState();
    undoAction.updateUndoState();
    protected void updateRedoState() {
    if (undo.canRedo()) {
    setEnabled(true);
    putValue(Action.NAME, undo.getRedoPresentationName());
    } else {
    setEnabled(false);
    putValue(Action.NAME, "Redo");
    private static void createAndShowGUI() {
    final TextComponentDemo frame = new TextComponentDemo();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
    public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    UIManager.put("swing.boldMetal", Boolean.FALSE);
         createAndShowGUI();
    class JavaFilter extends javax.swing.filechooser.FileFilter
    public boolean accept (File f) {
    return f.getName ().toLowerCase ().endsWith (".txt")
    || f.isDirectory ();
    public String getDescription () {
    return "Fisiere text (*.txt)";

    Hi,
    unfortunatly you cannot change the properties of Action object as you would do with JavaBeans. Instead you have to use the 'put' method.
    eg.:
    myAction.put(Action.SMALL_ICON, new ImageIcon(...));IMHO this was a bad decision, because it's not like the JavaBeans standard and you loose static type information. :-/
    -Puce
    Message was edited by:
    Puce

Maybe you are looking for

  • Problems sending email using Edge

    OK, I have my own email server hosted with the company that hosts all of my websites (Cyberwurx)... They use port 25 for their outgoing mail server. I am able to receive email just fine using WIFI or Edge. However, when using Edge I can not seem to s

  • How to convert raw to number in oracle 8

    Does anyone know how to convert a raw data to number format ??? If i do: select dump(50,16) from dual, it will return bytes c1 33. With this bytes in a raw variable, how can i convert it to a number variable in Oracle 8. PS: Oracle 8 doesn't have utl

  • Accessing Genius Playlists to save/amend

    Hello, all How do I save/modify a Genius mix genre? I can play it, but I can't see the playlist or save/modify it. Sometimes Genius almost hits my perfect list, and if I could change 2-3 songs, or even the order of play, it would be aural Nirvana. Th

  • How do I resolve duplicates in my conact lists?  Thank you

    I have lots of duplicates on my contact list. How do I resolve this issue?  Thank you

  • Examples on Web Dynpro Java ? For more practice purpose

    Hi EP experts     I want more examples on Web Dynpro Java for practice purpose     My project next phase is on full  webdynpro     Pl...provide me more worked examples but in SDN i found very few regards kiran LVS