• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

How to print something that is not set initially

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basically I need to make a program that will print out the animal letters that the user enters into a textbox. I don't know how many letters will be entered so I need to get it after the button has been pressed to define the animals[]. But this doesn't work, the print dialog box opens and nothing appears. Yet if I specify that animals was String[] animals = new String[5] at the beginning, I will get 5 pages in the print preview. How can I get this to show without specifying it ahead of time? thanks for any help, I've been stuck on this for days.

 
Sheriff
Posts: 22082
113
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post an SSCCE that shows the problem? Because I've created my own little SSCCE and it prints out what I expect.
 
Khoa Nguyen
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, so here is a working example. when I type in "cat, dog, cow" and press printer, I see that nothing has happened in the print preview. There should be 3 pages with cat dog and cow on them. I'm not sure what's going on?

 
Ranch Hand
Posts: 207
jQuery Eclipse IDE Firefox Browser
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I think its because you are creating a new instance of BillPrinter and passing it to setPrintable : printJob.setPrintable(new BillPrinter());

Instead this you should pass this reference to setPrintable: printJob.setPrintable(this);
 
Khoa Nguyen
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
that did it. Thanks
 
today's feeble attempt to support the empire
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic