Article View: borland.public.jbuilder.java.language
Article #17243Print JTextArea gives nullpointer exception?
From: Michael Appelmans
Date: Fri, 20 Nov 1998 00:00
Date: Fri, 20 Nov 1998 00:00
74 lines
3548 bytes
3548 bytes
I'm trying to print the contents of a textArea and get nullpointer
exception.
Any suggestions would be appreciated.
Here is sample snippet and errors:
Toolkit tk = Toolkit.getDefaultToolkit();
PrintJob pj = tk.getPrintJob(this, this.getTitle(),
printerSettings);
Graphics pg = pj.getGraphics();
jtaWatchText.print(pg);
pg.dispose();
pj.end();
Exception occurred during event dispatching:
java.lang.NullPointerException
at com.sun.java.swing.text.PlainView.paint(Compiled Code)
at com.sun.java.swing.text.DefaultTextUI$RootView.paint(Compiled
Code)
at com.sun.java.swing.text.DefaultTextUI.paintSafely(Compiled Code)
at com.sun.java.swing.text.DefaultTextUI$SafePainter.run(Compiled
Code)
at com.sun.java.swing.text.AbstractDocument.render(Compiled Code)
at com.sun.java.swing.text.DefaultTextUI.paint(Compiled Code)
at com.sun.java.swing.plaf.ComponentUI.update(Compiled Code)
at com.sun.java.swing.JComponent.paintComponent(Compiled Code)
at com.sun.java.swing.JComponent.paint(Compiled Code)
at java.awt.Component.print(Component.java:1381)
at java.awt.Container.print(Compiled Code)
at textwindow.Watch.printText(Watch.java:146)
at textwindow.WatchMenu.miPrint_actionPerformed(WatchMenu.java:165)
at textwindow.WatchMenu$4.actionPerformed(WatchMenu.java:91)
at
com.sun.java.swing.AbstractButton.fireActionPerformed(AbstractButton.j
ava:860)
at
com.sun.java.swing.AbstractButton$ForwardActionEvents.actionPerformed(
AbstractButton.java:895)
at
com.sun.java.swing.DefaultButtonModel.fireActionPerformed(DefaultButto
nModel.java:338)
at com.sun.java.swing.DefaultButtonModel.setPressed(Compiled Code)
at com.sun.java.swing.AbstractButton.doClick(AbstractButton.java:169)
at
com.sun.java.swing.plaf.basic.BasicMenuItemUI.processMouseEvent(Compil
ed Code)
at com.sun.java.swing.JMenuItem.processMouseEvent(Compiled Code)
at com.sun.java.swing.MenuSelectionManager.processMouseEvent(Compiled
Code)
at
com.sun.java.swing.plaf.basic.BasicMenuMouseListener.mouseReleased(Bas
icMenuMouseListener.java:37)
at java.awt.Component.processMouseEvent(Compiled Code)
at java.awt.Component.processEvent(Compiled Code)
at java.awt.Container.processEvent(Compiled Code)
at java.awt.Component.dispatchEventImpl(Compiled Code)
at java.awt.Container.dispatchEventImpl(Compiled Code)
at java.awt.Component.dispatchEvent(Compiled Code)
at java.awt.LightweightDispatcher.retargetMouseEvent(Compiled Code)
at java.awt.LightweightDispatcher.processMouseEvent(Compiled Code)
at java.awt.LightweightDispatcher.dispatchEvent(Compiled Code)
at java.awt.Container.dispatchEventImpl(Compiled Code)
at java.awt.Window.dispatchEventImpl(Compiled Code)
at java.awt.Component.dispatchEvent(Compiled Code)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
--
Michael Appelmans
Agility, Inc.
*SpamBam - remove 123 to mail*
mappelmans@123agility-inc.com
Technical Details
Message-ID:
<73h9tf$b8321@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,ade9b5d7132864dc,start X-Google-Attributes: gidf74b3,public From: "Michael Appelmans" <mappel@123ibm.net> Subject: Print JTextArea gives nullpointer exception? Date: 1998/11/20 Message-ID: <73h9tf$b8321@forums.borland.com> X-Deja-AN: 415570356 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="iso-8859-1" X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language