Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

System.setOut

807580Jun 8 2010 — edited Jun 8 2010
I'm having some problems changing System.out and System.err. This is the printstream I'm setting them to:
(con is a JTextPane)
    public final PrintStream out = new PrintStream(new OutputStream() {

        @Override
        public void write(int i) {
            try {
                Document d = con.getDocument();
                d.insertString(d.getLength(), String.valueOf((char) i), null);
                con.scrollRectToVisible(new Rectangle(0, con.getHeight(), 0, 0));

            } catch (BadLocationException e) {
                throw new RuntimeException(e);
            }
        }
    });
This is throwing all kinds of crazy exceptions from within my GUI code. Some are as follows:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at javax.swing.text.FlowView$FlowStrategy.layoutRow(FlowView.java:546)
	at javax.swing.text.FlowView$FlowStrategy.layout(FlowView.java:460)
	at javax.swing.text.FlowView.layout(FlowView.java:184)
	at javax.swing.text.BoxView.setSize(BoxView.java:380)
	at javax.swing.text.BoxView.updateChildSizes(BoxView.java:349)
	at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:331)
	at javax.swing.text.BoxView.layout(BoxView.java:691)
	at javax.swing.text.BoxView.setSize(BoxView.java:380)
	at javax.swing.plaf.basic.BasicTextUI$RootView.setSize(BasicTextUI.java:1702)
	at javax.swing.plaf.basic.BasicTextUI$RootView.paint(BasicTextUI.java:1421)
	at javax.swing.plaf.basic.BasicTextUI.paintSafely(BasicTextUI.java:722)
	at javax.swing.plaf.basic.BasicTextUI.paint(BasicTextUI.java:869)
	at javax.swing.plaf.basic.BasicTextUI.update(BasicTextUI.java:848)
	at javax.swing.JComponent.paintComponent(JComponent.java:752)
	at javax.swing.JComponent.paint(JComponent.java:1029)
	at javax.swing.JComponent.paintToOffscreen(JComponent.java:5124)
	at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:278)
	at javax.swing.RepaintManager.paint(RepaintManager.java:1224)
	at javax.swing.JComponent._paintImmediately(JComponent.java:5072)
	at javax.swing.JComponent.paintImmediately(JComponent.java:4882)
	at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785)
	at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713)
	at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693)
	at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
I really have no idea whats going on. If this is a better question for the SWING forum, move it. I thought it should be here since it's directly from changing System.out/err

Edited by: Colby_ on Jun 7, 2010 9:40 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 6 2010
Added on Jun 8 2010
3 comments
385 views