Hello,

So I'm thinking of creating a few programs that don't use the provided components like the Button class. Basically I want to create components like a button, text field... etc, but with their own look and feel to them. I tried overriding methods of existing components and I tried doing it from Component. Either way, something went wrong.

Basically my question is what is the right way of creating a component?
-How do I properly have the components redrawn every time an event happens (mouse over, mouse press, keyboard, etc)?
-If the component is not a square shape (like a circle), how do I avoid gray in the areas not drawn?
-What methods do I need to create / override when dealing with drawing?
-There are so many draw methods (paint, print, update, etc), what does each call/ do and how do they interact with each other?

Another thing I want to do is create an applet with animation and components on top. My idea is to have separate double buffers for each, so they can be independent of each other when drawing. What methods deal with components above and in what way?

Recommended Answers

All 6 Replies

So far what I've understood is that it's a good idea to separate the drawing, UI and data from each other.

After trying to understand the code, I'm even more confused. There's static classes which I don't understand and methods inside method calls.... which makes no sense.....

Where can I find the source code to JButton..... ?

Well I figured out some of the issues, the only problem I'm having now is how to draw the components/background behind the button from the button component.

Thanks, that did the job!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.