java.lang.Object
java.awt.PrintJob
- See Also:
- Source Code,
Toolkit.getPrintJob(java.awt.Frame, java.lang.String java.util.Properties)
public abstract void end()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void finalize()
- See Also:
end()
, Object
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract Graphics getGraphics()
- See Also:
PrintGraphics
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[378]AWT printing app
By latha on 2003/09/02 08:23:25 Rate
import java.awt.*;
import java.awt.event.*;
public class PrintingTest extends Frame implements ActionListener {
PrintCanvas canvas;
public PrintingTest ( ) {
super ( "Printing Test" ) ;
//canvas = new PrintCanvas ( ) ;
//add ( "Center", canvas ) ;
Button b = new Button ( "Print" ) ;
b.setActionCommand ( "print" ) ;
b.addActionListener ( this ) ;
add ( "South", b ) ;
pack ( ) ;
}
public void actionPerformed ( ActionEvent e ) {
String cmd = e.getActionCommand ( ) ;
if ( cmd.equals ( "print" ) ) {
PrintJob pjob = getToolkit ( ) .getPrintJob ( this,
"Printing Test", null, null ) ;
if ( pjob != null ) {
Graphics pg = pjob.getGraphics ( ) ;
if ( pg != null ) {
//canvas.printAll ( pg ) ;
//pg.setColor ( Color.black ) ;
pg.drawString ( "Hello All how !!!", 50, 50 ) ;
pg.drawString ( "Hello All how are!!!", 100, 100 ) ;
pg.drawString ( "Hello All how are u!!!", 150, 150 ) ;
pg.drawString ( "Hello All how are u doing!!!", 250, 250 ) ;
pg.drawString ( "Hello All TATA!!!", 350, 350 ) ;
pg.dispose ( ) ; // flush page
}
pjob.end ( ) ;
}
}
}
public static void main ( String args [ ] ) {
PrintingTest test = new PrintingTest ( ) ;
test.show ( ) ;
}
}
class PrintCanvas extends Canvas {
public Dimension getPreferredSize ( ) {
return new Dimension ( 100, 100 ) ;
}
public void paint ( Graphics g ) {
Rectangle r = getBounds ( ) ;
g.setColor ( Color.yellow ) ;
g.fillRect ( 0, 0, r.width, r.height ) ;
g.setColor ( Color.blue ) ;
g.drawLine ( 0, 0, r.width, r.height ) ;
g.setColor ( Color.red ) ;
g.drawLine ( 0, r.height, r.width, 0 ) ;
}
}
public abstract Dimension getPageDimension()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract int getPageResolution()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract boolean lastPageFirst()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public PrintJob()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples