Archive

Archive for the ‘Programming’ Category

Strange OS X SWT Table bug: scrollbar position wrong compared to content

June 8th, 2009 siker No comments

Today I saw a strange SWT bug which I couldn’t find much on when I searched for it online. In Mac OS X with a Table widget, sometimes pressing the Home or End keys on the keyboard would make the scrollbar move without the content actually moving. So for instance maybe you were scrolled towards the bottom and hit the Home key to get to the top: the bug would make you still see the same table rows even that the blue scrollbar marker would hop to the top. Even weirder, if you scrolled with the mouse wheel after that the scrollbar would snap right back to where you started and scroll like if you had never hit Home to begin with.

The solution was to add an SWT.KeyDown listener on the table and intercept any Home or End keyboard events. Set e.doit = false, then use table.setTopIndex() to change the viewing position in the table by hand. E.g. just reimplement the Home and End keys in your own code.

This worked fine for me.

iReport 1.2.7 Acrobat Preview

October 22nd, 2006 siker No comments

To automatically preview iReport PDF files using Adobe Acrobat Reader, go to Options/Settings/External Programs. For PDF Viewer, locate your Acrobat installation folder and select the AcroRd32.exe file.

Now this would work except that by default iReport 1.2.7 creates the PDF file in its home folder ".". This is a relative path and of course Acrobat has no idea what its relative to.

To fix this, go to Settings/Compiler and change ‘Default compilation directory’ from "." to a complete path like "C:\" or better yet "C:\Documents and Settings\USERNAME\My Documents".

Categories: Programming Tags:

Using subreports in Jasper iReport

October 20th, 2006 siker 2 comments

When trying to create a subreport in Jasper, I kept receiving the following error:

net.sf.jasperreports.engine.JRException: Could not load object from location

every time I tried to generate a sample PDF file. The subreport has its own SQL statement and needs to select data based on an id number passed as a parameter from the main report, so for the longest time I thought I was passing the parameter wrong.

Turns out that the real problem was in order to make a subreport work it has to be compiled. I had it compiled, but the compiled version of the resport (ending in .jasper) was being saved in a different folder. I didn’t know it was .jasper so I tried to specify every possible path to the .jrxml file which did not work.

So for anyone experiencing this problem, here’s what to do:

  1. Compile the subreport.
  2. Find the compiled .jasper file.
  3. Make sure your main report is referencing this .jasper file and nothing else.
Categories: Programming Tags: