Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

Where does paint get attached to an object?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had this working in some code, unfortunatley I've misplace the code. I found the coding on this forum so I am simple trying to ask for some clarification. I have my app looking like this so far.



Maybe its late, but I can't seem to get the draw code to affect my client area to draw the rectangle. Can anyone explain this paint method to me?

Kind of confused.
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

You need to swap lines 3&4.

I noticed you are using Frame (which is AWT). Instead, you should be using Swing (Google to get the AWT/Swing difference)
Almost all AWT components have a one to one Swing substitute.
Frame->JFrame
Button->JButton
Panel->JPanel

Also painting differs a bit when you are using swing. Check out http://docs.oracle.com/javase/tutorial/uiswing/painting/
 
Roses are red, violets are blue. Some poems rhyme and some don't. And some poems are a tiny ad.
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic