printing

Hi, everybody! I need your help. The problem is: I wanted to print out records from database, but it prints only odd or only even rows (it depends on the first

position of cursor - before first or first row).

The code fragment is:

......

ResultSet rs;

......

public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException {

.....

rs.next();

....

if (rs.isAfterLast()) {

return NO_SUCH_PAGE;

} else {

.....

g.drawString(rs.getString("NAME"), x, y);

...

return PAGE_EXISTS;

}

}

What should I add or change.

Thanks in advance

[686 byte] By [GoodCoff] at [2007-9-26 4:30:16]
# 1
Hi,you can't do it that way. The print() method could be called twice or more for the same page, depending on the page size. And you increase the row with rs.next() every time the paint() method is called (regardless of page number).Best regards,Martin
edosoft at 2007-6-29 17:42:32 > top of Java-index,Archived Forums,Java Programming...