Geiregat Jonas said:
I want to draw (squares ..) over a JTable,
I thoughed of making my own class, extending it with Jtable call paint
and start painting. Would this work ?
Maybe you find this helpful. Here is the code to draw a fillOval.
public class ColorCircle extends JComponent {
int drawX,drawY,dx,dy;
Color c;
public ColorCircle(int drawX, int drawY, int dx, int dy, Color c){
this.drawX = drawX;
this.drawY = drawY;
this.dx = dx;
this.dy = dy;
this.c = c;
}
public void setColor(Color c){
this.c = c;
repaint();
}
public void paintComponent(Graphics g){
super.paintComponent(g);
if (c != null){
g.setColor(c);
}
g.fillOval (drawX,drawY,dx,dy);
}
}
Then you can create the ColorCircle object and specify the location. Like this:
JPanel p = new JPanel();
ColorCircle s =new ColorCircle(280,0,18,18, p.getBackground());
s.setSize(20, 20);
p.add(s);
Hope this helps.
Erica