How print a page to the printer with String variable

I my name is Alexandre Lefebvre. Im in big trouble. All my program is finished. I must print only the String elements on a JTextArea to the printer (Hewllett-Packard 842c). Please help me.

Use the java 2d Api and printable interface together.
First, implement Printable Interface
your class extends XXXXX implements Printable
then use this..
public int print(Graphics g, PageFormat pf, int index)
if(index ! =0) return NO_SUCH_PAGE;
Graphics2D g2 = (Graphics2D)g;
g2.setColor(Any Color);
g2.drawString(textArea.getText());
return PAGE_EXISTS;
public void actionPerformed(ActionEvent ae)
if(ae.getSource() == printButton)
PrinterJob pj = PrinterJob.getPrinterJob();
pj.setPrintable(this);
if(pj.printDialog())
try
pj.print();
catch(Exception e){ // Handle }
This works fine for printing a single page. But you've got to use some logic and iterate the print job

Similar Messages

  • I connected my Canon printer to time capsule, and can print OK. However, I can't get the printer scanner to work. How do you set up the scanner with Time Capsule?

    I connected my Canon printer to time capsule, and can print OK. However, I can't get the printer scanner to work. How do you set up the scanner with Time Capsule?

    You cannot use USB. It has to be a network capable printer.. is it?? You did not indicate how it is connected.. but by wireless or ethernet then scanning is possible otherwise not.

  • How do I connect to the internet with my new IPAD ?

    How do I connect to the internet with myt new Ipad

    See here for connecting to the Internet:
    http://support.apple.com/kb/HT1695
    If you have any problems there is troubleshooting advice here: http://www.apple.com/support/ipad/wifi/

  • How do i connect to the internet with my ipad?

    how do i connect to the internet with my ipad?

    Did you turn WiFi on in the Settings App? If WiFi is turned on, your iPad should be able to see any WiFi networks that you can connect to and you should be able to tap on one of those, enter a password if needed and then tap the join button.
    I get the feeling that you know this and the problem needs further explanation so ... Can you explain in more detail?

  • How do i connect to the internet with apple tv

    how do i connect to the internet with apple tv

    Ethernet cable from your router, or configure wifi in Settings.

  • HT1338 i have apps to be updated but when i try to update them a message pops out saying "You have updates for other accounts, please sigh in with the other id". Can some one help me how can i still update the same with the new apple id ive created.

    i have apps to be updated but when i try to update them a message pops out saying "You have updates for other accounts, please sigh in with the other id". Can some one help me how can i still update the same with the new apple id ive created. As i dont have the access to the earlier id anymore.

    You cannot. The apps are assigned to that Apple ID and there is nothing you can do to change that. You could choose to download them again with the new Apple ID, any paid apps will need to be purchased again.
    Hope that helps.

  • I sold my ipad 2 and didn't take out my apple id. how can i log off the ipad with out having it in hand?

    I sold my ipad 2 and didn't take out my apple id. how can i log off the ipad with out having it in hand?

    You can't. But the buyer more than likely restored it because he/she could not use your Apple ID.

  • How do I make appear the "phone with skype"-link, ...

    How do I make appear the "phone with skype"-link, next to tel numbers on websites, that I visit ?

    Hi, filipfirmout, and welcome to the Community,
    In the Windows version, the settings to enable this are here:
    Tools -> Options -> Advanced -> check in Use Skype to call to links on the web -> Save.
    There is also this: http://www.skype.com/en/download-skype/click-to-call/
    Best regards,
    Elaine
    Was your question answered? Please click on the Accept as a Solution link so everyone can quickly find what works! Like a post or want to say, "Thank You" - ?? Click on the Kudos button!
    Trustworthy information: Brian Krebs: 3 Basic Rules for Online Safety and Consumer Reports: Guide to Internet Security Online Safety Tip: Change your passwords often!

  • How can I automatically create the files with serie-name?

    Hello, Everyone,
    I have a question again.
    How can I automatically create the file with a serie-filename?
    e.g. I have a program, it will repeat 5 times, and every time it will create a bmp-file, and I want to let this program automatically save these 5 files with a Serie-filename like File001.bmp, File002.bmp, .... File005.bmp.
    How can I do it?`
    Thanks a lot.
    Regarts,
    Johnny

    Hi Deepu,
    one more comment
    The format code should be "%04d" to get leading zeros and have filenames with same length...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • I have just owned a macbook pro and trying to learn things since i have all along used windows laptop. My first question is : when there are two files i am working together, one above the other on screen, how you switch over between the two with key ?

    I have just owned a macbook pro and trying to learn things since i have all along used windows laptop. My first question is : when there are two files i am working together, one above the other on screen, how you switch over between the two with key ?

    Hi...
    Mac OS X keyboard shortcuts
    Control-F4
    Move focus to the active (or next) window
    Shift-Control-F4
    Move focus to the previously active window
    By the way...  since you are new to Mac, click a clear space on your Desktop. You should see "Finder" top left corner of the screen in the menu bar.
    Click Help then click Help Center
    As an example type in    keyboard shortcuts
    You can use the Help menu for almost any application on your Mac.
    Apple - Find Out How - Mac Basics
    For held switching from PC to Mac >  Apple - Support - Switch 101

  • Problem with String variable

    I am new to Java Programming.
    I have a line of code that works and does what is supposed to.
    faceData.getProfile("Lisa").removeFriend("Curtis");
    If I assign the strings to variables such as-
    String name = "Lisa";
    String fName = "Curtis";
    and then plug those into the same line of code, it does not work
    faceData.getProfile(name).removeFriend(fName);
    What could be causing the problem?
    I even added some lines to print out what is stored in the variables to verify that they are what they should be, but for some reason the variables do not work while putting the strings in quotes does. Any ideas?

    I guarantee that something about your assertions are incorrect. Those variables are either not equal to the values you claim, or something else is going on. But it's not a problem with string variables versus string constants.
    Edit: My best guess in lack of a real example from you, is that the strings in question have non-printable characters in them, such as trailing spaces or line feeds.

  • How to allign text under the barcode with same width?

    Hi,
    I need to put a barcode in my form with the human readable text right under it and more importantly,irrespective of the number of digits of the text number, it needs to be space out exactly equal to the barcode length.can anyone please help with text formatting here? And what if the barcode might change in future? Something like below:
    IIIIIIIIIIIIIIIIIIIIIIIII
    1 2 3 4 5 6 7
    IIIIIIIIIIIIIIIII        
    1234567
    Edited by: Aditi Bhandari on Nov 22, 2009 3:38 PM

    For sapscripts and smart forms (what is your techno?), SAP allows you only to print barcodes (bars), not the texts corresponding to these barcodes, so you will have to implement a custom solution.
    As SAP doesn't provide you the actual width of the generated barcode, you will have to determine empirically the formula.
    I think it will be rather tough to use "space" characters or font size to manage the spacing between characters.
    Instead, I see 2 solutions:
    - send directly the text to the printer with the right Character Per Inch value : First calculate how many characters per inch you need (barcode estimated width divided by number of characters), then use print controls HEX - ENDHEX to define the instructions in printer language (for each device type you will print to). For better rendering use fixed font (COURIER, etc.) Note that it will work for printout, but not for print preview (text won't appear at all).
    - second solution would be to generate text as an image if you have such a software, and print the image. It will work well in all situations.

  • How to download Pages in The Netherlands

    Hi,
    Last week I was in New York, and I bought the iPad. I'm very happy with my recent purchase, but I would like to use pages before the iPad will be released in my country (July). I have a Dutch Appe ID, ofcourse, and a US Apple ID, without creditcard. Since my adress is linked to my creditcard details, I can't create an ID with creditcard, and Pages is not in the App Store yet. Does anyone have an idea on how to solve this? Thanks in advance!

    wouter
    make a new apple id ( with a new email) and set it up as being in the us
    I had to do this since some Dutch apps are not available in the US store, and being Dutch I wanted to have them
    you can message me privately if you want

  • Turning iBook pages on the iPad with the apple remote

    Something I'd love to see; using any reader; I have my pad on a stand; and Im engrossed in a book; with each page turn I have to lean forward and reach toward the screen; how great it would be to use the remote or an iphone in hand to turn the pages on the iPad screen. Is there an app out there that does this; or have I just given an idea to a developer....

    raspberryaddiction wrote:
    Obviously no technical solutions here; but a very entertaining lesson in the moral rectitude of effort LOL
    Moral rectitude? What's this the Sarah Palin school of language?
    Seriously, I don't read anything that far away. The iPad font would require a pair of binoculars. I suppose a remote would work then.
    As a medical professional, I'd suggest that we follow Occam's Razor (kind of corollary, I suppose) in that the easiest solution is the best. Go see an ophthalmologist. You need some reading glasses.

  • How do I connect to the internet with Airport for the first time?

    I just got my Airport express and I've been trying to configure it to connect to the internet but it doesn't work and I can't find info on the configurations. I have an ethernet "modem" which I used to connect the cable coming from it to the computer and now I connect it to my Airport. Although the green light is on and in network preferences, it tells me I'm connected to the internet, I can't browse the internet with Safari, etc. I've been trying to find information on how to configure the base station in Airport Admin Utility but there is no specific information. Is there anyone who could help me telling me how to set up the IP adress, if I need one, DHCP, preferences in Airport Admin Utility?? If the ethernet cable is connected to the computer directly I don't need a user ID or anything... It's all setup automatically.

    As a minimum, in order to gain access to the Internet with an AirPort Express base station, you will need an Internet Service Provider (ISP) AND an Internet modem or gateway device.
    What is the make & model of the Internet modem or gateway device that you have the AirPort Express directly connected to by Ethernet? What exact model of Express do you have?

Maybe you are looking for

  • Can I get an icloud email but NOT an icloud account?

    Everything is working fine as is, but I need a new email address.  I'd like to make use of .icloud.com address unless it means getting a brand new .icloud.com/Apple ID along with it. Thoughts?

  • Firmware Upgrade and Battery Life?

    Since the firmware upgrade on my Macbook in early February the fan appears to be running at full speed all the time and battery life is crap! Has anyone else noticed this? Is there a fix/workaround available please?

  • Change file name on upload in PHP

    HI Folks, I am trying to rename a file uploaded in a form using this. But nothing happens. I can't figure out why but I'm sure you guys will see the problem straight away. if(isset($_FILES['logo']['name'])) {$_FILES['logo']['name']=("".$row_rs_member

  • Unwanted Rank Order line deletion in Bank Determination in FBZP u0096 APP

    One more line item is being added and asking for a Rank Order (Mandatory Field) in Bank Determination (T/Code - FBZP - APP). Inspite of deleting the Payment methods / Rank Orders lines & after generating the Request (For the deletion of unwanted data

  • Issue in me9f transaction po printing.

    Hi      in me9f when try to print a po, there was a z program      ZPOPRINT which prints it, i think it is a routine.      it is giving a dump. i want information on routines      regarding this. Thanks & Regards, Abhimanyu.L