hanvyj 7 Posting Whiz in Training

I'm trying to print at a resolution other than 72 DPI, I managed this using the PrinterResolution (see the code below) but I am having a problem with the printable area. When I change the resolution to 300 DPI I just print everything smaller (ie the getImageableWidth() etc are still the same for 72 DPI) I was wondering how I can resolve this, I tried using MediaPrintableArea, but I dont want to limit my user to A4 (ie I would actually have to code the dimentions in mm) Is there any way I can get the MediaPrintableArea from the pageFormat?

This is my code:

PrinterJob printerJob;
	PageFormat pageFormat;
	int numberOfPages;
	private String units;
 
        public void printAllGraphs(){
		numberOfPages=this.dataList.size();
		System.out.println("Number of pages : " + numberOfPages);
		
		printerJob = PrinterJob.getPrinterJob();
		printerJob.setJobName(" Print Component ");
		printerJob.setPageable(this);
		
		int newResolution = 300; int oldResolution = 72;
		
		PrinterResolution pr = new PrinterResolution(newResolution,newResolution,PrinterResolution.DPI);
		
		PrintRequestAttributeSet p = new HashPrintRequestAttributeSet();
		
		setPageFormat();
		
		if (printerJob.printDialog() == false)
			return;
		try {
			p.add(pr);
			p.add(mpa);
			printerJob.print(p);
		} catch (PrinterException ex) {
			System.err.println(ex.getMessage());
		}
	}
	
	public void setPageFormat()
	{
		pageFormat = printerJob.pageDialog(printerJob.defaultPage());// = pj.pageDialog(pj.defaultPage());
	}
 
        public int print(Graphics g, PageFormat format, int pagenum) {
		// Tell the PrinterJob if the page number is not a legal one.
		if ((pagenum < 0) | (pagenum >= numberOfPages)) 
			return NO_SUCH_PAGE;
		
		//work out the size of the page
		int width = (int)(format.getImageableWidth());
		int height = (int)(format.getImageableWidth());
		int x = (int)format.getImageableX();
		int y = (int)format.getImageableY();
		
		// Clear the background to white
		g.setColor(Color.white);
		g.fillRect(x,y,width, height);
		
		BufferedImage image = chart.chart.createBufferedImage(width, height);		
		g.drawImage(image, x, y,width,height, null);
		
		// Tell the PrinterJob that we successfully printed the page.
		return PAGE_EXISTS;
	}

Thanks

ps, I have also posted this in the oracle forum http://forums.oracle.com/forums/thread.jspa?threadID=2134237&tstart=0 but considering the last post was 4 days ago, im not sure I will have any luck there...