🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Problems printing?

#19647
From: Todd Prisbe
Date: Thu, 08 Jan 1998 00:00
70 lines
2435 bytes
I'm having trouble getting printed output from a java application.  I get
the Windows print dialog box, but then all I get is a blank page.  My sample
printing app source code is below.  What am I doing wrong?

import java.awt.*;
import java.awt.event.*;
import java.util.Properties;
import borland.jbcl.control.*;

public class PrintTestApp extends Frame {
    TextArea ta = new TextArea();
    Toolkit tk;
    int screenWidth = 300;
    int screenHeight = 300;
    ButtonControl buttonControl1 = new ButtonControl();

    public static void main(String args[]){
        PrintTestApp app = new PrintTestApp();
    }

    public PrintTestApp() {
        try {
           setup();
           setSize(screenWidth, screenHeight);
           show();
            jbInit();
         }
         catch (Exception e) {
            e.printStackTrace();
         }
    }

    void setup() {
        tk = getToolkit();
        add("Center", ta);
    }

    public void jbInit() throws Exception{
          buttonControl1.setLabel("buttonControl1");
          buttonControl1.addActionListener(new
PrintTestApp_buttonControl1_actionAdapter(this));
          this.add(buttonControl1, BorderLayout.NORTH);
     }

    void buttonControl1_actionPerformed(ActionEvent e) {
        String name = "Test Print Job";
        Properties prop = new Properties();
        PrintJob pj = tk.getPrintJob(PrintTestApp.this, name, prop);
        if (pj == null) ta.setText("A null PrintJob was returned.");
        String output = "\nTest of printing";
        ta.setText(output);
        pj.getGraphics().dispose();
        pj.end();
     }

}

class PrintTestApp_buttonControl1_actionAdapter implements
java.awt.event.ActionListener {
    PrintTestApp adaptee;

    PrintTestApp_buttonControl1_actionAdapter(PrintTestApp adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.buttonControl1_actionPerformed(e);
    }
}
Technical Details
Message-ID: <693eaj$6i81@forums.borland.com>
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,d0dc6de8af7c3ea5,start
X-Google-Attributes: gidf74b3,public
From: "Todd Prisbe" <tprisbe@education.com>
Subject: Problems printing?
Date: 1998/01/08
Message-ID: <693eaj$6i81@forums.borland.com>
X-Deja-AN: 314060781
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4
Organization: None
Newsgroups: borland.public.jbuilder.java.language