aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes how to implement the main() in the following code? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to implement the main() in the following code?" Watch "how to implement the main() in the following code?" New topic
Author

how to implement the main() in the following code?

pandu chinnu
Greenhorn

Joined: Nov 21, 2006
Posts: 16
Hi there,

I was looking at this code in head first -



How do you implement the main method for this program?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
You'd do that by putting the JPanel inside of a JFrame. Here's an example of how that might work.


Ping & DNS - updated with new look and Ping home screen widget
pandu chinnu
Greenhorn

Joined: Nov 21, 2006
Posts: 16
Hi,

I added the following main to the previous code



the program runs creating an Orange rectangle inside a frame,,,thanks. I had thought that it would work if we called the paintComponent() from within main. What is the reason that it dosen't work that way?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
You shouldn't call paintComponent directly - Swing does that for you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to implement the main() in the following code?
 
Similar Threads
Rmi BAsic Problem
Method overriding from multiple interfaces
whats wrong with my code ?
Method overriding from multiple interfaces
Inheritance and exception