NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

NodeAction.performAction() deprecated, alternatives?

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users
View previous topic :: View next topic  
Author Message
bjarven



Joined: 17 Mar 2011
Posts: 50
Location: Sweden, Linköping

PostPosted: Tue Sep 12, 2017 7:59 am    Post subject: NodeAction.performAction() deprecated, alternatives? Reply with quote

Hi, I'm wondering if there's any other way of doing this other than the deprecated method NodeAction.performAction().

I have a class that extends NodeAction, and it has a popup presenter. To get the data from the selected menu item i use performAction. But it's deprecated, so I guess there's another better way of doing this... Any recommendations?

Code:

public class MyAction extends NodeAction{

    @Override
    public JMenuItem getPopupPresenter() {
        JMenu menu = new JMenu();
        menu.setText("My menu");
        for (int i = 0; i < myItems.length; i++) {
            ExtendedMenuItem item = new ExtendedMenuItem(key);
            item.setText(key);
            item.addActionListener(this);
            menu.add(item);
        }
        return menu;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        // need actionPerfomed to get information about the menu items!
        if (e.getSource() instanceof ExtendedMenuItem) {
            ExtendedMenuItem eItem = (ExtendedMenuItem) e.getSource();
            for (Node node : getActivatedNodes()) {
                // do something with the selected nodes depending on the menu choice
            }
        }
    }

    @Override
    protected void performAction(Node[] arg0) {
        // won't get any information about the menu here...

    }
}
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo