I would like to dynamically create a minimal transparent bar graph to display over a canvas.
I was thinking of using a custom renderer for a JButton or a JLabel; but how do I draw my bar graph in this renderer?
I would like to dynamically create a minimal transparent bar graph to display over a canvas.
I was thinking of using a custom renderer for a JButton or a JLabel; but how do I draw my bar graph in this renderer?
The standard way would be to create a subclass (possibly an anonymous one, if you prefer) of JLabel or JPanel and overload the paintComponent(Graphics g) method. You can then use the passed Graphics object to draw whatever rectangles (and so forth) that you need. For more information on that part of it, refer to the Java 2D Graphics Trail.
EDIT: Does that answer the question? I just re-read it and now I'm not sure.