Trying to pick up the printer

I have an example below using a simple gui that has print function in it. The aim of the program is when the user clicks on the print button that they can call p the print and print waht ever is in the text area. I'm not sure if i'm in the right forum now so bear with me.
If any one has any ideas or knows how to fix it theres one error in total on the tool kit, its fairly well commented now so hope fully some one can see the problem is fairly annoying
Help wold ge great thanking you
Ambrose
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import java.awt.PrintJob;
import java.util.List;
//import sun.tools.javac.Main;
public class print extends JPanel {
    private JButton jButton14;
    private JTextArea jTextArea1;
    public print() {
        //construct components
        jButton14 = new JButton ("print");
        jTextArea1 = new JTextArea (5, 5);
        //adjust size and set layout
        setPreferredSize (new Dimension (496, 371));
        setLayout (null);
        //add components
        add (jButton14);
        add (jTextArea1);
        //set component bounds (only needed by Absolute Positioning)
        jButton14.setBounds (210, 245, 100, 20);
        jTextArea1.setBounds (25, 55, 435, 160);
     public void jButton14_actionPerformed(ActionEvent e)
          printText(jTextArea1.getText());
// Draw individual lines from the text onto pages of a new print job
    private void printText(String text)
        PrintJob p = getToolkit().getPrintJob(this, "Print Job", null); // This causes the print dialog box to pop up
        int pageLength = p.getPageDimension().height; // Find out page size
        StringTokenizer theText = // Prepare to break up the text into lines (one line = one token)
            new StringTokenizer(text, "\n", true); // Returns \n tokens too
        Graphics g = null;
        int lineInc = 0;
        int initialYForPage = 0; // y coord of top line on page
        int yMax = pageLength - 100; // y coord of bottom line, allowing for borders of 50 top and bottom
        int x = 0;                // Initial print position
        int y = initialYForPage;
        int pageNumber = 0;
        boolean newPage = true; // To force page layout initialization
        while (theText.hasMoreTokens()) {           // Scan the lines in theText
            if (newPage) { // Start of a page?
                g = nextPage(p); // Yes, set up new page
                lineInc = g.getFontMetrics().getHeight(); // The line height in pixels for the current font
               y = initialYForPage;
               pageNumber++;
                g.drawString("Page " + pageNumber, x, y);      // Page number at top
                y += 2 * lineInc;           // Space for a blank line
                newPage = false;
            String nextBit = theText.nextToken(); // Get next line or \n if it's an empty line
            if (nextBit.equals("\n")) // End of an empty line?
                nextBit = ""; // Yes, prepare to output an empty line
            else // No, we got a line
            if (theText.hasMoreTokens()) { // \n following?
          String discard = theText.nextToken(); // Yes, discard the \n following the line
            // System.out.println(nextBit);       // Just to check, during testing
            g.drawString(nextBit, x, y);      // Draw next line
            y += lineInc;     // and move down a bit (x doesn't change: always draw at left)
            if (y > yMax) {      // At end of page?
                g.dispose();           // Yes, print it
                newPage = true;      // Force page initialization if there's another page
        if (!newPage)
            g.dispose(); // Print last page, if not already done
        p.end(); // End of print job - phew!
    } // printText
    // Grab a new page for printing on
    private Graphics nextPage(PrintJob p) {
        Graphics g = p.getGraphics();
        g.translate(50, 50); // To move image away from top left of page
        g.setFont(new Font("SansSerif", Font.PLAIN, 10));
        return g;
    } // nextPage
    public static void main (String[] args) {
        JFrame frame = new JFrame ("print");
        frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add (new print());
        frame.pack();
        frame.setVisible (true);
}

Sorry the problem was in this line of code it picks up the gettoolkit as an error and when i excute the frame nothing happens
PrintJob p = getToolkit().getPrintJob(this, "Print Job", null);

Similar Messages

  • I have a Canon LBP5360 laser printer connected via USB cable to my MacPro running 10.6.8  I have downloaded the latest UFR2 divers. I am trying to connect to the printer but the printer is not showing appearing in Print

    I have a Canon LBP5360 laser printer connected via USB cable to my MacPro running 10.6.8 
    I have downloaded the latest UFR II driver. (UK Version)
    I am trying to connect to the printer but the printer is not  appearing in my Print/Fax Preferences.
    When I click the box "More Printers" under the Default printer the drop down box gives me a heading "Canon IPv6 (UFRII) with the option to add or cancel. (The add is highlighted). But there are no printers showing in the box. Nothing. Can anyone help?
    Is there a problem with my Mac setup or maybe a setting in my printer?

    Mac UFR II Printmonitor
    UFR II Printmonitor is application software that interfaces with the software for the printer, and is installed with the printer driver. You can start UFR II Printmonitor in the following folder to check the printer status, and errors. Refer to the Help how to use the Print Monitor.
    MF3010, MF8000 Series, MF8000C Series, MF8300 Series, MF8300C Series:
    Print Monitor: [Library] - [Printers] - [Canon] - [CUPSCMFP] - [Utilities]
    Other Printers:
    Print Monitor: [Library] - [Printers] - [Canon] - [UFR2] - [Utilities]

  • Picking up the printer settings for Double or single sided?

    Hi All,
    Do anyone have a solution for picking up the printer settings for the PO SAPscript so that if the printer can do double sided it should print double sided but if it can only do single sided, it should print single sided?
    Thanks & Regards,
    Sudheer.

    Hi Frank
    1. To change it manually you have to deselect the following option:
    Edit>Preferences>Type> Use Typographer's Quotes.
    2. To access the option through vb script use the following syntax:
    Document.TextPreference.TypographersQuotes
    May be this will help you.

  • I keep getting an error message when I try to print. I have tried ctrl/p, and the print command in my email both give me the same error message

    It has been for a month or 2 that I have not been able to print anything in my Firefox browser (It used to work just fine). I have no problem at all printing in Chrome ( I never use Internet Explorer ). Is it possible that my new printer is the problem? I had an HP now I have an Epson. That is the only change I have made that I am aware of.
    A few weeks ago I had to print out an email, but the only way I could get it printed was to take a screen shot and paste it in a program that would print it.
    The error message I get is: Printer Error An error occurred while printing.

    See this - https://support.mozilla.org/en-US/kb/fix-printing-problems-firefox
    Specifically see this paragraph - [https://support.mozilla.org/en-US/kb/fix-printing-problems-firefox?esab=a&s=reset+printer&r=5&as=s#w_reset-all-firefox-printer-settings Reset all Firefox printer settings]

  • Tried both ways in the Wiki, still can't get network printing work

    Hi,
    I have tried both the client and server ways following the Wiki, still could not get network printing work.
    For the first way, I tried to put either the host name or the ip address (starting with 192) of the remote printer into /etc/cups/client.conf. But both Okular and Evince failed to see the printer in the dialog.
    For the second way, with cups-browsed running, it only managed to discover printers in my local network (ip starting with 137) which I have no access. I tried to manually add the printer using its ip, but it still did not work.
    What can I do? I have spent hours trying to work it out but failed. I would appreciate a lot your help. Thanks.

    Have you looked at the previous discussions listed on the right side of this page under the heading "More Like This"? Ones with a green checkmark are solved.

  • Query based report to pick up the value from differences table

    Hi,
    I am trying to pick up the value from change log differences feild but since it is system variable i am unable to pick it.which table i should pick up to get that .
    Regards-
    Monica.

    Hi Monica,
    This would be a tough job if you know the structure of the historical record tables.  You need to familiar with all those A tables first.  Any changes to one of the record would create a instance of the record before change.  AITM is for OITM, AIT1 is for ITM1 etc.  Which tables are you looking for?
    Thanks,
    Gordon

  • Connecting to the printer, driver problem

    I'm trying to connect to the printer (hp business inkjet1100) that's connected to a computer running xp (pro sp3) from my laptop running vista (home prem 64x). That just seems confusing reading that so: (printer)>>>(xp/desktop)<<<(vista/laptop). I already have a network set up and can share file with no problems, so I thought it'd be easy to connect to this printer. I was wrong.
    I try to connect to the printer by going to control pannel>printers>add printer>networked printer>printer's name after making it share on the xp computer (the name showed up on the vista computer so there's no problem there). Then vista tried to connect to the printer (bless it's heart) but had a problem (no suprise) it couldn't find a driver and wanted me to manually find the .inf file. No problem I'll just download the driver for the hp website, right? Wrong.
    Apparently there are no drivers for my printer for windows vista, however there is a workaround. You can use the drivers for the 1000 series printer and basic functions should work (hopefully that includes printing). The problem is that the workaround tells me to manually set up the printer (port, driver, etc) and then reconnect the printer to the computer (the problem being the printer isn't connected to the computer in the first place).
    Now I consider myself pretty good with computer and able fix most problems without help (and unfortunatlly end up helping plenty of the family with their problems), but this is just annoying. So I decide it's time to call in the experts (from india).
    I choose the live chat becuase it always seems faster and I haven't yet had one that would play me music while I wait (some may consider this a positive thing). The problem is that I have to find my serial number and product number. I copy down the 2 easily labled numbers, but that isn't the right combonation. So I search for "finding product number" and I get a page just like what I search for (finally some luck). After clicking on printers I get to a page called "Finding Your Product Name." At this point I give up on the hp website and just write down every number on the back of the printer. Finaly the stars align and I get to start chatting with a person. A couple of auto messages pop up and then he asks me to confirm the information I just entered (if it was wrong how did I get into the live chat?) and then continues to inform me that my warrenty has expired and it'll be $25 for support. I ask him if there is any other type of support and he says that the most he can do (probono) is give me a link to a webpage on the hp site (I've been there believe it or not), I thank him for his time and move on. Hopefully the expired warrenty doesn't matter here (but if it does just ignore that part it was a total lie just to see if you'd really help a guy without a warrenty (to test if you were really good people or just .....))
    Thanks in advance for your time
    Additional details:
     Laptop: AMD, Vista home prem 64bit
    Desktop: Intel, XP Home Pro 32bit (x86)
    This question was solved.
    View Solution.

    The following worked for me, even allowing me to manually select the driver
    Alternative method 1. 1. Click on the Windows icon>>Start Search>>Type printers and press enter. 2. Click on 'Add Printer'. 3. Click on 'Add a local printer'. 4. Click on 'Create a new port:'. 5. Do not change the 'Type of port:'. By default it is selected as 'Local Port'. Let it remain the same. 6. Click on 'Next'. 7. In the small 'Port name:' window, type the following under 'Enter a port name:'
      NOTE: The names should be exactly the same. They are case sensitive.
      \\computer name\printer name   
      For instance: If computer name is 'John' and printer name is 'HPprinter', you have to type the exact name with all the characters including spaces. Hence in this case it would be the following:
    \\John\HPprinter
    8. Click on OK.  9. Click on Next and complete the Wizard. (It will now install the printer and driver) I used the 7400 series driver for my 7550 but it works.10. Try to print a Windows test page and check the printer functionality. 1 Click on the Start icon on your Desktop.2.Select Control Panel.3.Double click on the Printer icon.4.Select and Right click on HP Photosmart 7550 Printer series icon.5.Click on Properties.6.In the Properties Windows click on Print Test Page Tab it will start printing a Windows Test Page
    2

  • How to setup  the printer Urgent

    Hi Gurus,
    I m trying to setting up the printer , please guys help me out i gone thru SPAD , but i could't able to setup please guys help me out it's very urgnet

    Dear Reddy,
    please follow
    SPAD->Configration>Output Devices>change>create-->user defined Output device and Short name
    in Device attributes--- (if you trying to access a frontend printer on windows platform )
    select device type as SAPWIN :Rel.4.x/SAPlpd 4.09+ ONLY!
    Device Class as Standerd printer in next tab (Access Method) for Host Spool Acess Method : F:printing on Front End Computer(for this you need to install the printer in your system(the front end) )
    if you are not able to follow please let me know
    Regards
    George

  • I can't set up the Printer!

    I was trying to set up the printer to use my printer: Canon IP3000.
    However, whenever I connect the USB to my iBook G4, it didn't work at all.
    I went to "System Preference" to fix that problem, I went to Printer and clicked on "add" and select "USB". Didn't work at all.
    Somebody help me!

    The download's link was on the first page of Canon USA. Here is the printer page - don't remember which printer you had but they are all listed here - you will have to see if there is anything about leopard compatibility when you get to your particular drivers.
    http://www.usa.canon.com/consumer/controller?act=ProductCatIndex1Act&fcategoryid =103

  • Printing photos from the HP Photosmart 6515- won't pick up the photo paper

    I am trying to print photos from my HP Photosmart 6515. I have loaded the photo paper as the videos show, but the printer does not want to pick up the photo paper. I keep getting an error messge that says I am out of paper. If I put regular paper back into the printer, it will print on the regular paper, but not the photo paper. What am I doing wrong?

    Hello jackie4,
    I understand you are getting an 'Out of Paper' error when trying to pick up photo paper on your Deskjet 3515. I would like you to go ahead start troubleshooting An 'Out of Paper' Message Displays on the Control Panel and the e-All-in-One Does Not Pick Up Paper ....
    Please let me know if this was successful at resolving the error message, if you require more assistance I would be happy to help.
    Thanks,
    HevnLgh
    I work on behalf of HP
    Please click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" to the left of the reply button to say “Thanks” for helping!

  • HT4356 My iPad does not find the printer. I have tried the HP app and it works, but in any other app the printer is not seen. How do I get this printer visible to the iPad. All my other network computers find and print with out a problem.

    My iPad does not find the printer. I have tried the HP app and it works, but in any other app the printer is not seen. How do I get this printer visible to the iPad. All my other network computers find and print with out a problem.

    hi
    could you tell us what the other app is please

  • Hi I'm trying to install an HP C4180 printer as net printer through Alicegate router (Thompson technicolor). Printer works ok when connected with USB to Macbook air, but cannot be seen on the printer installation configuration. Mac OSx 10.7 (Lion)

    Hi folks.
    From this morning I'm trying to "see" an HP printer C4180 connected on the USB port of the wi-fi router (TIM Alicegate ADSL2 Wifi+N, manufacturer Technicolor).
    I installed latest drivers and checked everything is ok and works fine until printer is connected directly with USB to my Macbook Air.
    Then I connect the USB to the router and try to find the printer.
    On Alice help suggest to find it by ging to system preferences, then printers, add printer with "+", select "windows" sheet. There I can see - not always in reality, but sometimes - the "workgroup" in the left column, select, "alicegate" in second column, select, and here instead of finding the printer list there is a pop up saying that "the server version you are trying to connect to is not supported".
    Reading other forums, it may seem that the problem is Lion not yet supporting this kind of connection.
    Here a photo of the situation when the message occurs:
    Help..
    Thanks and regards
    Luca

    anchio ho lo stesso problema con Mas Os x 10.7.4
    con il sistema 10.5 funziona perfettamente
    credo sia un problema del sistema
    ho provato con 10.8 stesso problema
    ciao

  • I am trying to connect a Windows 7 / 64 bit to an Epson printer on my Mac.  The printer is hooked into the Mac via USB; the Mac is networked to a Linksys wireless router with an ethernet cable, as is the Windows box. Any tips on how to do this?

    I am trying to connect a Windows 7 / 64 bit to an Epson printer on my Mac.  The printer is hooked into the Mac via USB; the Mac is networked to a Linksys wireless router with an ethernet cable, as is the Windows box. I installed the current Bonjour printer services software on the Windows machine, and separately installed the driver software for the Epson printer on the WIndows machine.  Running the bonjour wizard, I get an alert saying 'I don't have sufficient access to my computer to connect to the selected printer'.
    The printer has 'sharing' turned on from the Mac end; this works with a Powerbook via the wireless connection.  Sharing is also turned on in the Windows printer control panel for this printer (under properties).  The Mac is a G5 running 10.5.8.  When I try to print a page from the Windows machine it gets hung in the print queue.
    Any advice how to proceed would be appreciated!
    thx,

    I am trying to connect a Windows 7 / 64 bit to an Epson printer on my Mac.  The printer is hooked into the Mac via USB; the Mac is networked to a Linksys wireless router with an ethernet cable, as is the Windows box. I installed the current Bonjour printer services software on the Windows machine, and separately installed the driver software for the Epson printer on the WIndows machine.  Running the bonjour wizard, I get an alert saying 'I don't have sufficient access to my computer to connect to the selected printer'.
    The printer has 'sharing' turned on from the Mac end; this works with a Powerbook via the wireless connection.  Sharing is also turned on in the Windows printer control panel for this printer (under properties).  The Mac is a G5 running 10.5.8.  When I try to print a page from the Windows machine it gets hung in the print queue.
    Any advice how to proceed would be appreciated!
    thx,

  • I'm trying to print  an Ancestry document from an iPad 2 using air print onto a Canon 5350 (one of the printers ok'd by Apple) I am unable to change the print orientation from portrait to landscape.  That is I change it in printer settings but no use.

    I'm trying to print an Ancestry document from an iPad 2 using air print.  The printer is a Canon MG5350 (on the Apple approved list) I have no difficulty printing but only in portrait format.  I've tried changing printer preferences from my computer but even though the Canon accepts the changes it will not print landscape - can anyone advise please?

    Hi,
    How do you connect the printer to the XP machine ? If USB, you need to make that machine as a Print server. Please try this:
       http://techtips.salon.com/make-windows-computer-pr​int-server-11914.html
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • I was trying to install a coupon printer software.  It seems to be stuck in the installation.  How can I quit it?  I tried quit and it won't work.

    I was trying to install a coupon printer software from a website and it seems to be stuck. It has been installing it for hours. When I click on the installer and try to quit it won't let me.  Any suggestions on how I can stop this?

    Click the Apple icon in the upper left corner and choose Force Quit. Look for the item that says Not Responding and force quit it.

Maybe you are looking for

  • New install of Crystal 2013 Server; getting errors

    New install of Crystal 2013 Server on Windows 2012R2 Server In the Connectivity Services; the ConnectionServer32 shows a state of Initalizing, and Disabled In the Crystal Report Services; the CrystalReports2013ProcessingServer shows a state of Runnin

  • How do I recover my Pictures I lost when I updated to the lates Icloud last saturday , I updated to the IOS 5.1 and all my pictures and Videos where lost

    I was unable to recover my Pictures and Videos after updating to ios5.1 ,please how can I recover my pictures and videos which was lost after updating to ios 5.1 on 12.11.2011

  • Possible to Adjust Swap Memory?

    Hi, I've recently begun SNMP monitoring on a 10.4.x system. I'm receiving an alert on OID memSwapError.0 with a threshold of 0. According to the notes in the OID setup, it means that very little swap space is left. Does anyone know how to resolve thi

  • Duplicate entries in reporting

    Hello gentlemen, SELECT CompName.Name0 as 'Computer Name', BIOS.SerialNumber0 as 'SN', CompSys.Manufacturer0 as 'Manufacturer', CompSys.model0 as 'Model', OU.System_OU_Name0 as 'OU' FROM V_R_System as Sys inner JOIN v_GS_PC_BIOS as BIOS on Sys.resour

  • MacBook Pro 10.8 problems

    Hardware Overview:   Model Name:    MacBook Pro   Model Identifier:    MacBookPro3,1   Processor Name:    Intel Core 2 Duo   Processor Speed:    2.2 GHz   Number of Processors:    1   Total Number of Cores:    2   L2 Cache:    4 MB   Memory:    2 GB