Search code examples
javaswingsubroutine

Is there any method of calling a subroutine or function within a newly opened frame? Java


I know how to call up one class from within another:

 new frame().setVisible(true);

But I don't know how you do this but call up a subroutine on that at the same time e.g

new frame().setVisible(true);
Sub123();

Solution

  • Assign the result of the new command to a variable and interact with it

    frame aframe = new frame();
    aframe.setVisible(true);
    aframe.Sub123();
    

    You may also consider taking a look at Code Conventions for the Java Programming Language