Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Edited code does not run correctly

  1. #1
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Edited code does not run correctly

    this does not work properly only the file reader bit does, no printer options is ever displayed
    Where does the code call any printer methods?

    Do you know how to call a method?
    http://docs.oracle.com/javase/tutori...arguments.html
    If you don't understand my answer, don't ignore it, ask a question.


  2. #2
    Junior Member
    Join Date
    Dec 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Edited code does not run correctly

    Thanks this was the issue, i did update the original question as i am now getting errors, but it seems to have vanished

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Edited code does not run correctly

    java.lang.NullPointerException
    at java.text.AttributedString.<init>(AttributedString .java:127)
    at PrintText.<init>(PrintText.java:14)
    There is a variable with a null value when line 14 is executed.
    Look at line 14 and find the variable with the null value. Then backtrack in the code to see why that variable does not have a valid, non-null value.

    Please edit your post and wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  4. #4
    Junior Member
    Join Date
    Dec 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Edited code does not run correctly

    Thank you, the code at line 14 was in the wrong place, i have now put this into the print method, however i am now getting this error

    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    	at java.text.AttributedString.<init>(AttributedString.java:127)
    	at PrintText.print(PrintText.java:109)
    	at sun.print.RasterPrinterJob.printPage(RasterPrinterJob.java:1973)
    	at sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1461)
    	at sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1277)
    	at PrintText.printer(PrintText.java:98)
    	at PrintText$1.run(PrintText.java:52)
    	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721)
    	at java.awt.EventQueue.access$200(EventQueue.java:103)
    	at java.awt.EventQueue$3.run(EventQueue.java:682)
    	at java.awt.EventQueue$3.run(EventQueue.java:680)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:691)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
    	at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Edited code does not run correctly

    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at java.text.AttributedString.<init>(AttributedString .java:127)
    at PrintText.print(PrintText.java:109)
    Now look at line 109 the same way you looked at line 14 in the previous error.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 2
    Last Post: November 18th, 2012, 02:09 PM
  2. My code is not working correctly
    By shavek911 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: July 18th, 2012, 05:49 PM
  3. How do I embed my code correctly?
    By jwise95 in forum The Cafe
    Replies: 1
    Last Post: April 22nd, 2011, 09:36 AM
  4. How to run this code?
    By jackdear44 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 1st, 2010, 11:37 PM
  5. Code not printing correctly
    By Movies32 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: February 6th, 2010, 03:59 PM