🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #19123

Printing from an Java Application.

#19123
From: Bas Passon
Date: Mon, 09 Mar 1998 00:00
42 lines
2036 bytes
Hi,

I'm curently working on a project for the KUN and I am having problems
with printing from the apllication. I have the following source.

void print_item_actionPerformed(ActionEvent e) {
    Frame printframe = new Frame();
    Properties prop = new Properties();
    PrintJob message;
    Graphics myGraphics;
    String msg_text = "A Java Print test by Bas Passon.";

    message =
Toolkit.getDefaultToolkit().getPrintJob(printframe,"test1",prop);
    myGraphics = message.getGraphics();     //(LINE 184!)
    myGraphics.drawString(msg_text,50,100);
    myGraphics.dispose();
    message.end();
  }

When I compile and try to print the Execution log says the following:

AppAccelerator(tm) 1.1.2.018 for Java (JDK 1.1), x86 version.
Copyright (c) 1997 Borland International. All Rights Reserved.
Exception occurred during event dispatching:
java.lang.NullPointerException
	at sun.awt.windows.WGraphics.drawChars(Compiled Code)
	at sun.awt.windows.WGraphics.drawString(Compiled Code)
	at MessageView.print_item_actionPerformed(MessageView.java:184)
	at
MessageView_print_item_actionAdapter.actionPerformed(MessageView.java:222)
	at java.awt.MenuItem.processActionEvent(MenuItem.java:336)
	at java.awt.MenuItem.processEvent(MenuItem.java:307)
	at java.awt.MenuComponent.dispatchEventImpl(Compiled Code)
	at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:138)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:65)

I just want to printout some text. What am I doing wrong?

Greetings Bas Passon.
basp@sci.kun.nl
Technical Details
Message-ID: <350400D9.936971A1@sci.kun.nl>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,4bff4117d72011c8,start
X-Google-Attributes: gidf74b3,public
From: Bas Passon <basp@sci.kun.nl>
Subject: Printing from an Java Application.
Date: 1998/03/09
Message-ID: <350400D9.936971A1@sci.kun.nl>
X-Deja-AN: 332268719
Content-Transfer-Encoding: 7bit
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Organization: KUN
Newsgroups: borland.public.jbuilder.java.language