I have been tinkering with the java.awt.print and javax.print APIs. The answer to your problem would be in these two. I have tried printing and got some "successes". Bottomline: you will have to implement the Printable interface and "draw" what you want to print on a Graphics or Graphics2D object then return a defined integer representing if the printing is valid or not. Using java.awt.print, you will need to set the Paper object and those you will have to print would be in a Book object.
You may want to look at "Beginning Java 2" by Ivor Horton (Wrox publishing). The book has got some examples on printing. Good ones too.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I saw this on your code. I was downloading it when I made my first message (sorry).
In GantDiagram.java:
<code>
public int print(Graphics g, PageFormat pageFormat, int page)
{
if (page != 0) {
return Printable.NO_SUCH_PAGE;
}
paint(g);
return Printable.PAGE_EXISTS;
}
</code>
This will print a blank page because "nothing" is drawn on your Graphics object g.
What I would suggest is that you have another method that does the painting (returns a Graphics) to be called by both paint() and print() methods.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am sorry again. I didn't see the paint(g) line.
Still that wouldn't do anything on the Graphics object in print() because calling paint(g) I think would "paint" on the GUI and "not" on the paper.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
.....print(Graphics g, PageFormat p, int page) {
if .....
}
g = getDrawing();
return Printable.PAGE_EXISTS;
}
public Graphics getDrawing() {
Graphics g = __?_.getGraphics();
......
......
return g;
}
Hope this helps. :)
PS
I am sorry if i seem to mess up a bit(your discussion board i mean). i'm at my office desk fighting off boredom and stress and its late night friday when i happen to browse this page.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have been tinkering with the java.awt.print and javax.print APIs. The answer to your problem would be in these two. I have tried printing and got some "successes". Bottomline: you will have to implement the Printable interface and "draw" what you want to print on a Graphics or Graphics2D object then return a defined integer representing if the printing is valid or not. Using java.awt.print, you will need to set the Paper object and those you will have to print would be in a Book object.
You may want to look at "Beginning Java 2" by Ivor Horton (Wrox publishing). The book has got some examples on printing. Good ones too.
I saw this on your code. I was downloading it when I made my first message (sorry).
In GantDiagram.java:
<code>
public int print(Graphics g, PageFormat pageFormat, int page)
{
if (page != 0) {
return Printable.NO_SUCH_PAGE;
}
paint(g);
return Printable.PAGE_EXISTS;
}
</code>
This will print a blank page because "nothing" is drawn on your Graphics object g.
What I would suggest is that you have another method that does the painting (returns a Graphics) to be called by both paint() and print() methods.
I am sorry again. I didn't see the paint(g) line.
Still that wouldn't do anything on the Graphics object in print() because calling paint(g) I think would "paint" on the GUI and "not" on the paper.
Suggested routine:
....paint(Graphics g) {
g = getDrawing();
....
}
.....print(Graphics g, PageFormat p, int page) {
if .....
}
g = getDrawing();
return Printable.PAGE_EXISTS;
}
public Graphics getDrawing() {
Graphics g = __?_.getGraphics();
......
......
return g;
}
Hope this helps. :)
PS
I am sorry if i seem to mess up a bit(your discussion board i mean). i'm at my office desk fighting off boredom and stress and its late night friday when i happen to browse this page.
Thanks for your help!
We've received a complete patch for the GanttDiagram class and included that in v0.0.5. I hope you don't mind :-)