Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

questions about a java bean

  Asked By: Loretta    Date: Feb 13    Category: Java    Views: 673

I'm trying to make my first java bean. It extends JPanel. I view it
by instantiating an instance of it within a JPanel, which is itself
on a JFrame.

1. I try to use setFont twice within the bean's paint method, so I
can have 2 different fonts on the bean's display. This doesn't
work. Seems I can only use setFont once. Is there some way I can
reset Fonts within a single paint method?

2. I want to change the background color of the bean. Within the
bean's paint method, isOpaque tells me I've successfully made the
bean opaque, and getBackground tells me I've successfully changed the
background color to white. Yet, it always displays as default gray.
Any ideas about what I'm doing wrong?



1 Answer Found

Answer #1    Answered By: Edward Jones     Answered On: Feb 13

I solved the problem with background  color. For reasons unclear to
me, adding "super.paintComponent(g);" to the top of my paint method
solved the problem.
Any advice regarding the setFont question would be appreciated.

Didn't find what you were looking for? Find more on questions about a java bean Or get search suggestion and latest updates.