Article View: borland.public.jbuilder.java.language
Article #14528Re: help on File output
From: Celil Germeyan
Date: Mon, 30 Aug 1999 00:00
Date: Mon, 30 Aug 1999 00:00
123 lines
5019 bytes
5019 bytes
This is a multi-part message in MIME format.
------=_NextPart_000_000C_01BEF2D3.FB592FE0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Please try the following code:
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.lang.*;
import java.sql.*;
import java.lang.*;
import java.util.*;
import java.applet.Applet;
public class cgprn1 extends Applet {
public void init() {
PrintJob pj =3D getToolkit().getPrintJob(null, "My Print Job", =
null);
if (pj !=3D null) {
Graphics pg =3D pj.getGraphics();
Dimension d =3D pj.getPageDimension();
pg.setFont(new Font("Courier", Font.PLAIN, 10));
pg.drawString("Hello",100,100); /* x,y */
pg.drawString("World\n",100,115); =20
// the page is sent to the printer
// when the graphics object
// is disposed.
pg.dispose();
pj.end();
}
// else the user canceled out of the
// print options dialog
}=20
}
jmurrayassoc <murrayja@concentric.net> wrote in message =
news:37C6D4AF.17DB8DD6@concentric.net...
This may be more an IDE question but here it is.
How the %$*&^ do you send something to the printer? I open an output
stream to 'PRN:' ( microsofts standard file name) and it fails to =
open.
I can open any ordinary file using local terminology, eg 'c:\\foo,txt'
and write to it ok.
jim murray
------=_NextPart_000_000C_01BEF2D3.FB592FE0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2014.210" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Please try the following code:</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2>import java.awt.*;<BR>import =
java.awt.event.*;<BR>import=20
java.io.*;<BR>import java.lang.*;<BR>import java.sql.*;<BR>import=20
java.lang.*;<BR>import java.util.*;<BR>import =
java.applet.Applet;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2>public class cgprn1 extends Applet {<BR> =
public=20
void init() {<BR> PrintJob pj =3D=20
getToolkit().getPrintJob(null, "My Print Job",=20
null);<BR> if (pj !=3D null)=20
{<BR> Graphics pg =3D=20
pj.getGraphics();<BR> =
Dimension=20
d =3D =
pj.getPageDimension();<BR>  =
;=20
pg.setFont(new Font("Courier", Font.PLAIN,=20
10));<BR> =20
pg.drawString("Hello",100,100); /* =
x,y=20
*/<BR> =20
pg.drawString("World\n",100,115); =
<BR> =20
// the page is sent to the printer<BR> // when the graphics=20
object<BR> // is=20
disposed.<BR> =20
pg.dispose();<BR> =20
pj.end();<BR> }<BR> // else =
the user=20
canceled out of the<BR> // print options =
dialog<BR> }=20
<BR>}<BR></FONT></DIV>
<DIV> </DIV>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: =
0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
<DIV>jmurrayassoc <<A=20
=
href=3D"mailto:murrayja@concentric.net">murrayja@concentric.net</A>> =
wrote in=20
message <A=20
=
href=3D"news:37C6D4AF.17DB8DD6@concentric.net">news:37C6D4AF.17DB8DD6@con=
centric.net</A>...</DIV>This=20
may be more an IDE question but here it is.<BR>How the %$*&^ do =
you send=20
something to the printer? I open an output<BR>stream to 'PRN:' ( =
microsofts standard file name) and it fails to open.<BR>I can open any =
ordinary file using local terminology, eg 'c:\\foo,txt'<BR>and write =
to it=20
ok.<BR><BR>jim murray<BR></BLOCKQUOTE></BODY></HTML>
------=_NextPart_000_000C_01BEF2D3.FB592FE0--
Technical Details
Message-ID:
<7qdbvf$59q4@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<37C6D4AF.17DB8DD6@concentric.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,a5bf7bf23bb0effa X-Google-Attributes: gidf74b3,public From: "Celil Germeyan" <itg@turk.net> Subject: Re: help on File output Date: 1999/08/30 Message-ID: <7qdbvf$59q4@forums.borland.com> X-Deja-AN: 518777798 References: <37C6D4AF.17DB8DD6@concentric.net> X-Priority: 3 Content-Type: multipart/alternative; boundary="----=_NextPart_000_000C_01BEF2D3.FB592FE0" X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 Organization: Another Netscape Collabra Server User X-MSMail-Priority: Normal Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language