• Post Reply Bookmark Topic Watch Topic
  • New Topic

using textArea for drawing surface in netbeans  RSS feed

 
Arian Gerryts
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am learning about the method painComponent(Graphics) and this method I think belongs to the JComponent class and any component inherits from JComponent inherits this method to be overidden.

If I add a textArea (areaDrawing) for example to the form from the pallet, how can I specify that this area should be used as drawing surface. I.o.w. using Netbeans, how could I specify that the paintComponent(Graphics) of the textarea should be implemented if I click on a button for example.

Should I create a separate class that extends JTextArea for example and then add this to the Frame by using the constructor?

Kind regards
 
Randall Twede
Ranch Hand
Posts: 4696
8
Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for beginning i would use JPanel instead o f JTextArea.
how could I specify that the paintComponent(Graphics) of the textarea should be implemented if I click on a button for example.

in your actionPerformed just call repaint()
 
Arian Gerryts
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, thanks. Better to create entire GUI using constructors as well as JPanel.


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!