Calling content public static void main in another class

I have classes Embed.java and watermarkdemo.java

There are several lines of code in the main Embed.java method. I want to call the main Embed.java method in the actionPerformed () method when the user clicks the insert button. Please can someone give me an outline of how this can be done?

I hope I understand clearly in my problem, and it’s easy for me to understand what I’m actually saying. Thankyou

+4
source share
3 answers
public void actionPerformed(ActionEvent e) { ... Embed.main(null); // or a String[] containing args you want to pass ... } 

Just like a pie.

+5
source

This is called "calling static methods"

 onemethod() { AnotherClass.anotherMethod(); 
0
source
 Embed.main(); 

If your main method implements varargs, then you will need to pass something. If it implements during an array, you need to pass an empty array.

Personally, although I would think about refactoring the code you need into a separate method. Basically you are likely to have all of your settings that you might not want to run again

0
source

All Articles