1

I have a MyCanvas class that extends JComponent. On this canvas I have drawn a couple of things and has its own main method.

    public static void main(String args[]) {
    JFrame mainFrame = new JFrame("Graphics demo");
    mainFrame.getContentPane().add(new Canvas0_1());
    mainFrame.pack();
    mainFrame.setVisible(true);   }

How do I call to load the canvas from my program's other main method. Is this possible?

gobernador
  • 5,659
  • 3
  • 32
  • 51
marcoamorales
  • 625
  • 2
  • 10
  • 13

1 Answers1

2

It is possible but probably not what you need. If you insist just try:

class OtherClass {
   public static void main( String [] args ) {
       MyCanvas.main( args );
   }
}

And that's it.

I think it will be better if you create an instance of your canvas and add it to another component and not use it directly from main

OscarRyz
  • 196,001
  • 113
  • 385
  • 569