![]() |
| ||
| calling another function in nested class this is my code.. class NewAction implements ActionListener sorry for my newbie question but can we actually call the actionPerformed method inside the NewAction class from the confirmation method?? i did try some like this.NewAction().actionPerformed(); myclass.NewAction.actionPeformed(); NewAction().actionPerformed(); NewAction.actionPerformed(); i dont know any possibilities anymore.. help me please.. i changed the NewAction class become public but still doesnt work.. thanks |
| ||
| Re: calling another function in nested class Think about what you're doing: You want to call a method on a class, so you'd better make sure you have an instance of that class. In this case that class is an inner class to another class, so you must first have an instance of that other class. That leads you to something like this.new NewAction().actionPerformed(); |
| ||
| Re: calling another function in nested class it doesnt work, but thanks i think it is better to changet the hierarchy, i realize that my code is confusing |
| ||
| Re: calling another function in nested class well, based on your bit of code something like that should work. Problem is that that code is rather ambiguous and it is of course not at all clear what you're actually trying to accomplish. |
| ||
| Re: calling another function in nested class ok then, actually i am making a notepad like program, i want whenever i press the "New" , "Open", Exit" buttons, it will prompt me for saving, but now i am confused with this.. |
| ||
| Re: calling another function in nested class You could of course just put that code in a regular method and call it from your other listeners. Why do you feel it needs to be another class? If it does need to be a class, then yes, you can call it like jwenting wrote, but of course you will need to supply the method parameter. A null will suffice if you aren't actually using the ActionEvent param for anything. If you tried to call it with no parameter then certainly it didn't work. |
| ||
| Re: calling another function in nested class i think u shud try the following: (new NewAction()).actionPerformed();just one extra () :) |
| All times are GMT -4. The time now is 10:17 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC