This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't get PaintComponent to work :(

 
Atsuko Maeda
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm doing a word search game. I'm just starting to learning java so it might be a stupid mistake. My problem is that I can't get the PaintComponent to work even though I already tried every possible thing that I know. Please help me! Where should I put paintComponent?



 
Maneesh Godbole
Saloon Keeper
Posts: 10973
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch
Hint: Have you added the Grid to the frame at all?
 
Atsuko Maeda
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i tried putting this code in the createAndShowGUI() method but still no luck
 
Maneesh Godbole
Saloon Keeper
Posts: 10973
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In pseudo code
Create a JPanel instance (which has the overridden paint method)
Create a JFrame instance
Add the panel instance to the frame instance
Show the frame
Recommended reading http://docs.oracle.com/javase/tutorial/uiswing/painting/step2.html (It would be a very good idea to read it right from the start http://docs.oracle.com/javase/tutorial/uiswing/painting/)
 
Atsuko Maeda
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I made my code like this still doesn't work. In creating a Jpanel instance does it mean that I have to put JPanel panel = new Jpanel("") etc? Sorry my mind doesn't really work well now.
 
Atsuko Maeda
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i see the problem now. I think i should do something to this part but I'm not sure what. When I removed this part of the code the Jpanel with the text appeared. Can you give me a hint? I tried reading several sources but I still can't figure it out.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic