I know this is gonna be a stupid question. Pardon me as a n00b into CS
I have a new swing component that inherits from JComponent. I am trying to paint lines on its surface to show that the lines split the control into equal parts. The code looks like
int spc;
spc = (int) Math.round((this.ZBar.getWidth() / this.ZBar.getModel().getModelSize()));
for (int i = 0; i <= this.ZBar.getModel().getModelSize(); i++) {
g.drawLine(i * spcing, 0, i *, this.ZBar.getHeight());
}
this.ZBar.getModel().getModelSize(); gives out number of parts to split into. However, in some cases there is some more space left on the right most end of my component. I guess it is gue to the Type conversion done by Math.round. How can I solve this ??