Using PrintJob need help

Sup guys,
I have a question regarding how to use PrintJob class. Here is what I am trying to do, I am writing a simple gui app that takes the values from users and stores how many labels users want into a array.
So I get all the labels in the array and now I want to print them out of the array on the printer.
Two things, how dose someone go about setting up a PrinterJob so it reads the values from array and then sends it to the printer?
Also since I am printing labels this will be printed on a certain format. Now I use word to print these labels and they have a code in the word for it 5267, so I am not sure how I can get the program to print in that format so the labels come lined up correctly on the label sheet.
Is there another class in java that lets me import the word document and read the format and then somehow use that as a blueprint for what dimensions to use when printing?
Sorry, I am new to java so I am trying to figure out how these classes work and how to connect them together to get the program to do what I want.
Thanks for any help

Lovac,
You should read more about Swing. There is a class called java.awt.print.PrintJob
for example
the method below will print the printable component; so your label should be layed on a printable component ( any component which implement Printable interface
such as you an have a class called MyJPanel which extends JPanel and implements the interface Printable;
example below show a printjob usage;
public void printData() {
          try {
               PrinterJob prnJob = PrinterJob.getPrinterJob();
               prnJob.setPrintable(m_panel); // the m_panel extends JPanel and implements Printable interface
               if (!prnJob.printDialog())
                    return;
               setCursor( Cursor.getPredefinedCursor(
                    Cursor.WAIT_CURSOR));
               prnJob.print();
               setCursor( Cursor.getPredefinedCursor(
                    Cursor.DEFAULT_CURSOR));
               JOptionPane.showMessageDialog(this,
                    "Printing completed successfully",
                    APP_NAME, JOptionPane.INFORMATION_MESSAGE);
          catch (PrinterException e) {
               e.printStackTrace();
     }Please take a look at java tutorial at http://java.sun.com/docs/books/tutorial/ui/features/index.html as a starting point
Regards,
Alan Mehio
London,UK

Similar Messages

  • Query off of Oracle using WinSql - Need help with query

    I am trying to query off of Oracle using program WinSql.
    I have a table(tticpr200110) that has the following sample data:
    ITEM     CODE     T$AMNT
    23500076 ACL     .0049
    23500076 APM     0
    23500076 APO     .0093
    23500076 EXP     .0001
    23500076 RES     .0072
    and what I want it to look like is:
    ITEM     ACL     APM     APO     EXP     RES
    23500076     0.0049     0     0.0093     0.0001     0.0072
    (actually I need the last 2 columns added together to be MATL-but can deal with that down the road).
    Seems simple enough, but I don't know to put into the columns.
    Any help would be GREATLY appreciated as soon as possible would be even better.

    My table - tticpr200110 when it runs I get the following sample data for part number 23500076:
    The first coloumn ITEM is the part number.
    The second column CODE is 1 of 5 different cost codes
    The third column is the cost for that code for that part.
    ITEM CODE AMNT
    23500076 ACL 0.0049
    23500076 APM 0.0000
    23500076 APO 0.0093
    23500076 EXP 0.0001
    23500076 RES 0.0072
    I want to make a query that makes the data look like this:
    ITEM ACL APM APO EXP RES
    23500076 0.0049 0.0000 0.0093 0.0001 0.0072
    (similar to a pivot table in excel or acess)
    I hope this helps better.
    Thanks!

  • Wanting to use ichat, need help

    Hi all,
    this is just a quick question any help would be greatly appreciated. I want to use ichat as i hear it is easy and nice and able to video chat, but i dont have/dont want to get a .mac account. i have a hotmail and gmail account, is this going to be possible?
    thanks all

    Hi
    You will need a free .mac account http://www.apple.com/dotmac/ click on free trial and name will still work after the 60days.
    Free AIM name HERE
    Setup iChat http://www.ralphjohnsuk.dsl.pipex.com/page2.html
    To setup gtalk http://www.google.com/support/talk/bin/answer.py?answer=24076
    For MSN on jabber in iChat http://allforces.com/2005/05/06/ichat-to-msn-through-jabber/
    Jabber severs for MSN http://www.jabber.org/network/oldnetwork.shtml
    Tony

  • Web Guy Using Swing - Need Help With jComboBox

    I'm new to doing desktop Java development (come from a web application background) and am trying to accomplish migrating some of a web application's functionality to a desktop app for distribution. I'm already a bit stuck when it comes to using the jComboBox. What is intuitive to me in the web world would be to have one combo box/select box that after making a selection, it returns it's value so I could use that to run another query that would populate the next drop down menu. Populating the display of the combo box isn't the problem, that seems easy enough, but what I so far can't find is how I can attach a value to the combo box; that is for instance, having the drop down show a list of country names, and needing to have that list of country names correspond to a country code. For the web, you'd just have the option value tied to the code and the contents of the option be the name.
    Is this do-able? Am I completely thinking about this in the wrong way when working in desktop GUI things? I am using NetBeans 6.0 for my GUI layout and such, don't know if that helps or hurts matters. Also currently using Java 1.5.
    Any information or points in the right direction are greatly appreciated.
    Cheers.

    If I understand you correctly, you need to have a class that holds country name and country code, with a toString override method that returns just the country name (this is what the combobox shows). You then put an array of these objects in your jcombobox, obtain the selected object, get it's country code, and you're off and running.
    Edited by: Encephalopathic on Mar 31, 2008 3:26 PM

  • Web Conferencing Using JTAPI - Need help

    Hi,
    I have to work on "Web Conferencing" application, but i don't have any idea how this can be done in Java.
    I heard that, JTAPI can be used for this purpose.
    Please tell me anyone, is it possible to do Conferencing type of application using JTAPI.
    If so what are the Requirements for that?
    Do we need to use any specific kind of telephone devices??+
    Give me some idea how to begin with this, and any source where i can get all the details about this.
    Thanks for any help.....
    Thanks,
    Sharath

    Take a look at the SIP servlet projects such as Sailfin if you want to deal with traditional PSTN.

  • Using "Git", need help...

    Heya,
    So I installed Git on my SLS and successfully initialized a repository but when I try and clone it from a remote computer (my Macbook) I get this error:
    Could not chdir to home directory /dev/null: Not a directory
    bash: /dev/null/.bashrc: Not a directory
    bash: git-upload-pack: command not found
    fatal: The remote end hung up unexpectedly
    I don't understand what this error is and a search on Google doesn't help any...

    are you running this under a git account with no defined homedir?
    that's my guess. you need to provide more details.
    also, check out this and this:
    http://github.com/sitaramc/gitolite
    http://progit.org/book/ch4-8.html

  • USING JCreator Need help

    I am using JCreator to compile and run my programs. I can get the programs to compile fine, but when I go to run them I get an error.
    The error says : Exception in thread "main" java.lang.NoClassDefFoundError: New\java
    press any key to continue.
    I am not sure if the classpath or path is right or not
    Please help guys.

    HERE IS THE COMPLETE CODE
    THIS WAS A SIMPLE CODEYou do have a / before these asteriks , right?
    >
    * @(#)New.java 1.0 03/09/17
    * You can modify the template of this file in the
    * directory
    ..\JCreator\Templates\Template_1\Project_Name.java
    * You can also create your own project template by
    making a new
    * folder in the directory ..\JCreator\Template\. Use
    the other
    * templates as examples.
    class New {
         //A Java program begins with a call to main().
         public static void main(String args[]) {
              System.out.println("This is cool.");

  • Just bought used MBP, need help registering Mountain Lion

    Hi guys, I'm very new to the Apple community. I recently bought a used Macbook Pro (October 2011) on eBay, the seller tells me that in order to actually use this computer, I need an Apple ID and have bought/downloaded Mountain Lion.
    I want to get this all sorted out before I recieve my MBP in the mail. Here's my problem, I have obviously made an Apple ID, however I can't seem to buy and download Mountain Lion on this site......I'm using a PC laptop currently. I don't have access to any other Mac computer to buy a copy of Mountain Lion (if that even is the correct terminology) in the meantime.
    Is this whole process even necessary? What should I do?
    Thanks,
    Devin B

    With Apple's new delivery system of the OS and the new licensing requirements to go along with it, it has become ridiculously confusing. Have the seller use Internet Recovery and do the following: boot holding down Command + Option + R to get to Disk Utility. Wipe the drive. Reinstall Mac OS - using the internet recovery will reinstall the original system (whereas using the regular recovery will reinstall the current system), so he must use the internet recovery. Shut down computer when it is either done installing, but just before the setup screen comes on. You can boot up and set it up using your own ID. Later, you can buy Mountain Lion and install it. This should work (no guarantees though - the "official" way from Apple is for the seller to contact iTunes and un-register his license in an email to them advising them that you will be buying it). That info is from a senior advisor at Apple.
    With all this, remind the seller to also deauthorize the computer in iTunes.

  • Can't use Qmaster; need help

    Hi all,
    I've read all the recent threads here and I've tried everything everyone has suggested but Qmaster is still not working for me. Here's my setup:
    * Quad G5 with OS X 10.4.4 with all updates (incl. QT 7.1)
    * Intel Mac mini; OS same as above
    * Final Cut Studio 5.1 on G5
    * Qmaster alone on mini
    * connected via switch on same subnet
    I tried the quick setup guide and it didn't work. Jobs get processed but only by the controller.
    I've tried setting up a manual cluster using Qadministrator but have the same problem: on the mini, the icon in the toolbar flashes green but then goes back to grey and the job is processed on the G5.
    I used Media Manager in FCP to copy all the media and the sequence to a network share that the mini had access to (read and write). I then exported the sequence from FCP as a refernce movie to the same location. I specified that Compressor should never copy the source. I also made sure the setting in Compressor didn't require to FCP to be installed on all the nodes.
    When that didn't work, I opened the Qmaster preferences and set the cluster storage to be the same network share; I'm not sure if that's neccessary.
    I've just about given up with Qmaster. I've tried everything I can think of and tried all the tips here with no luck at all. I'd much appreciate any advice.
    Regards,
    fh

    Fergus,
    I am also new on this thing. I also encountered problems which are not yet answered in this forum. I am continuing to fix it though. On the other hand, I was able to successfully set up my Qmaster. This is what I did:
    1. Make sure that FIREWALL is disabled to all computers.
    2. Make sure all computers have the application, i.e. Shake, installed.
    3. If you have Compressor in your system. Make sure that Apple Qmaster apps have the same version with the Compressor App.
    4. Set up one computer as a Cluster controller. Go to it's systems prefs > Apple Qmaster. Enable "Services and Controller Cluster". Make sure you have checked the "Managed" option in the Services. The click "Start Sharing". If you have enabled the sharing before, you may want to reset it first by pressing "Option" button, the "Start Sharing" button will be converted to "Reset Services".
    5. Set up your other computers a service nodes. Go to it's systems prefs > Apple Qmaster. Enable "Services Only" option. If you have enabled the sharing before, you may want to reset it first by pressing "Option" button, the "Start Sharing" button will be converted to "Reset Services".
    6. Get back to your Computer hosted as a cluster controller. Open Apple Qadministrator. Then create a new cluster. You should be able to see now that names of the service nodes in the "Qmaster Service Browser". Add them, to the Cluster you've just made.
    7. When your finished, click on "Apply."
    8. Open "Apple Qmaster" application to the computer where you want to submit a job. You should be able to see now the name of the cluster you've made on the "Submit to" field.
    9. Add a job, say Shake, by clicking on the sign or drag and drop the shake script in the Apple Qmaster field.
    10. Double click on the submitted job. And make sure you have the correct path for your shake application in the shake field. Something like this: /Applications/Shake/shake.app/Contents/MacOS/shake
    11. Click "OK".
    12. Click "Submit".
    13. If you followed it correctly. You should be able to see the processing of your submitted jod in the "Batch Monitor" window.
    Hope it helps.
    Cheers!

  • Migrating from Eclipse/Ant/MyFaces Trinidad to using JDeveloper--need help

    I recently downloaded JDeveloper 11.1.1.2.0. Several years ago, I used JDev to do some very simple JSP/servlet development with no formal framework. Times have changed a lot.
    For the past few years, I have been developing server-side Java web apps using Eclipse JEE and Ant (ie, everything is set up so that the developer does not depend on the IDE). We currently implement web apps using Apache MyFaces Trinidad JSF components (but not Facelets). Any developer here can check out our code and simply run Ant to build the projects--no need to even have Eclipse installed. Anyone here can build and develop with a text editor and Ant, if they prefer.
    I am impressed and yet overwhelmed by the robust functionality of the latest JDev--so impressive, but I feel almost a bit too removed from "seeing" what is going on in the code and deployment. I like the notion of drag-and-drop along with wizards, but I want to also know how the JDev project is set up manually; ie, where everything goes, without having to guess on this. I get the impression that I need to learn, very specifically, the framework of ADF. But unfortunately, the tutorials seem to focus on only using the wizards and drag-drop functionality.
    For example, how do I set up JDev to build a project only by running Ant using my properties files and build.xml? This is trivial to do in Eclipse by specifying the Project Builder. Is there some similar setting I can use in JDev?
    Is there full compatibility with Trinidad--didn't Oracle make the original Trinidad?
    Has anyone posted advice on migrating from Eclipse JEE to JDev?
    Sorry if this is an old set of questions; if I had known where to search for this information, I would not be posting this thread.
    Many thanks!
    Mike Quentel

    The basic steps for bringing your existing code into JDeveloper are:
    Import->WAR File - or alternatively create a new application and in it create a new projects->project from existing source
    The next couple of steps have to do with setting the project properties:
    Then you need to set up your project content path (specifically things like Web content and resources content)
    Then you need to add the jars/libraries in your project classpath and libraries.
    A few related link:
    http://blogs.oracle.com/shay/2010/01/migrating_from_netbeans_to_jde.html - netbeans migration but similar concepts
    http://www.oracle.com/technology/products/jdev/howtos/1013/w4wljdev/workshopandjdev.html - basic migration from Eclipse to JDeveloper
    http://blogs.oracle.com/shay/2009/02/using_trinidad_in_jdeveloper_1.html - Using trinidad in JDeveloper
    Also don't forget that you can now set your JDeveloper accelerators to be based on Eclipse key mapping - might make the migration easier.

  • My Final Cut Pro X quits unexpectantly and shuts down which makes it impossible to use..need help asap

    Went I went to grab some pictures that I had downloaded from the web, FCP X shut down and sent a message to APPLE.  I have tried deleting the pics and this morning it was working for a little while but it shut down again.  I need to get FCP working properly. 

    Same thing happened to me yesterday. It started after there was a sudden electricity shut off when I was playing with FCP X. I do not have Compressor installed. I eventually managed to get FCPX to work again when I manually deleted in Finder the project on which I was working when the electricity went off.
    I hope this information may give you some ideas on your problem.
    Mannnolo

  • I am making a movie on my ipad using iMovie, need help with music.

    I have a song that I put into my itunes library and then uploaded it into a dropbox folder.  I have dropbox on all my apple products.  Anyway, I would like to use this song in my imovie project.  How do I get it into imovie from dropbox.  It is a an aif. file.
    THANKS!  Kelly

    What you share on iTunes file share is the project itself, not the final video. Press share > camera roll. And then you can access the video on explorer/finder as any other photo.

  • True or False using RadioCheckbox - need help ASAP

    So I've been working my way through java with self-study. Our teacher gave us knoweldge not applicable to what he's asked us for our project (except logic). Basically, he wants us to present questions, have the user answer them, then show the number of correct answers.
    I'm now using checkboxes in a True or False 10-item test. I once used buttons, but I gave up and went to checkboxes. I managed to display them using this:
    Parameters:
    tofp = true or false panel
    tofql = true or false question label
    tofqp = true or false question panel
         if(e.getActionCommand().equals("True or False"))
              f2.hide();
              JPanel tofp = new JPanel();
              JPanel tofp2 = new JPanel();
              JPanel tofqp = new JPanel();
              JPanel tofqp2 = new JPanel();
              JPanel tofqp3 = new JPanel();
              JPanel tofqp4 = new JPanel();
              JPanel tofqp5 = new JPanel();
              JPanel tofqp6 = new JPanel();
              JPanel tofqp7 = new JPanel();
              JPanel tofqp8 = new JPanel();
              JPanel tofqp9 = new JPanel();
              JPanel tofqp10 = new JPanel();
              FormPanel3 = new JPanel();
              JLabel tof = new JLabel("<html><Font size=5>TRUE OR FALSE</font> </html>");
              JLabel tofql1 = new JLabel("<html>1. CFC, found in refrigerator and <P> aircons , means Chlorofluorinechloride.</html>");
              JLabel tofql2 = new JLabel("<html>2. Endangered species are species <P> that are less in number and are nearly extinct.</html>");
              JLabel tofql3 = new JLabel("<html>3. The smallest fish in the world <P>is the sardines. </html>");
              JLabel tofql4 = new JLabel("<html>4. The agents of soil erosion are <P>wind, water, and human.</html>");
              JLabel tofql5 = new JLabel("<html>5. One way of conversing energy is <P> by using fluorescent light.</html>");
              JLabel tofql6 = new JLabel("<html>6. The use of dynamite is a legal method <P> of fishing.</html>");
              JLabel tofql7 = new JLabel("<html>7. Windmill is an example of a potential <P>energy.</html>");
              JLabel tofql8 = new JLabel("<html>8. Tamaraws are found in Mindanao.</html>");
              JLabel tofql9 = new JLabel("<html>9. Mining causes minimum destruction to <P> our environment.</html>");
              JLabel tofql10 = new JLabel("<html>10. The Philippines is called the Pacific <P>Ring of Fire because of the many <P> volcanoes surrounding it.</html>");
                b4 = new JButton("Submit");
                b4.addActionListener(this);
              tofp.setPreferredSize(new Dimension(400,550));
              tofqp.add(tofql1);
              tofqp2.add(tofql2);
              tofqp3.add(tofql3);
              tofqp4.add(tofql4);
              tofqp5.add(tofql5);
              tofqp6.add(tofql6);
              tofqp7.add(tofql7);
              tofqp8.add(tofql8);
              tofqp9.add(tofql9);
              tofqp10.add(tofql10);
              tofp.add(tof);
              tofp.setBackground(Color.yellow);
              tofp.add(tofqp);
              tofp.add(tofqp2);
              tofp.add(tofqp3);
              tofp.add(tofqp4);
              tofp.add(tofqp5);
              tofp.add(tofqp6);
              tofp.add(tofqp7);
              tofp.add(tofqp8);
              tofp.add(tofqp9);
              tofp.add(tofqp10);
              tofp.add(b4);
         JRadioButton True = new JRadioButton("True");
             True.setActionCommand("True");
             True.setSelected(false);
         JRadioButton False = new JRadioButton("False");
             False.setActionCommand("False");
             False.setSelected(false);      
             ButtonGroup group = new ButtonGroup();
             group.add(True);
             group.add(False);
             JRadioButton True2 = new JRadioButton("True");
             True.setActionCommand("True");
             True.setSelected(false);
         JRadioButton False2 = new JRadioButton("False");
             False.setActionCommand("False");
             False.setSelected(false);      
             ButtonGroup group2 = new ButtonGroup();
             group2.add(True2);
             group2.add(False2);
             tofqp.add(True);
             tofqp.add(False);
               tofqp2.add(True2);
             tofqp2.add(False2);
              FormPanel3.add(tofp);
              FormPanel3.add(tofp2);
              FormPanel3.add(tofp2);
              f3.setContentPane(FormPanel3);
              f3.pack();
              f3.show();     
              f3.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              f3.setResizable(false);I intentionally just have 2 groups of radio button displayed to test if I could tally the right answer. No luck.
    I'm a complete beginner to this sort of thing, as in starting from scratch. But if I were to apply what our teacher taught us, this would be a simple boolean program. Unfortunately, this kind of thing isn't too simple for me.
    So how do I tally the right answer upon clicking 'submit'. I know you have to have a new frame for that, but it's about tallying. Like the right answer for number 1 is false, for number 2 is true. If you click Submit, I should be able to show "You got 1 correct answer".

    Tan-Tan wrote:
    I'm now using checkboxes in a True or False 10-item test. I once used buttons, but I gave up and went to checkboxes. I managed to display them using this:I'm confused. So does your code use JRadioButtons (like your code says), or JCheckBoxes (like this sentence says)?
    I intentionally just have 2 groups of radio button displayed to test if I could tally the right answer. No luck.How did you attempt to tally the right answer? How do you have the right answers stored? How were you getting the status of each JRadioButton?
    So how do I tally the right answer upon clicking 'submit'. I know you have to have a new frame for that, but it's about tallying. Like the right answer for number 1 is false, for number 2 is true. If you click Submit, I should be able to show "You got 1 correct answer".Worry about how you display the tally later. For now just use a System.out.println. I'd use a for loop to get the status of each JRadioButton or JCheckBox, and check that against an array of correct answers.

  • Washington State now requires hands-free use: we NEED help from Apple

    While iPhone pairs seamlessly with bluetooth-capable automobiles, users will nonetheless struggle to comply with laws that mandate hands-free phone usage in our cars. Answering calls is easy, but in order to dial in hands-free mode we need either
    1) Voice-dialing
    -or-
    2) Complete contact list transfer, enabling one-touch dialing features already built into our cars.
    At this time iPhone offers neither, and since I have to look at the screen to dial a contact I'd be in violation of the law when relying on my iPhone in the car to make calls.

    My car has voice operated dialling (Honda Civic).
    I program my numbers in the car via voice and allocate then a voice command (like "Mother").
    Then all I do is press the button on the steering wheel and say "Dial Mother' the car repeats back to me "Do you want to dial Mother?", I press the button again and say "Yes", the car says "Dialling".
    It then connects to the phone dials the number and the audio in and out is sent via the car microphone and speakers. It even directs the sat nav commands to the opposite side speaker so that you hear two distinct voices.
    Ian

  • Plan to Travel With an iPhone, I will NOT Use Data, Need HELP

    So in a week I leave for a month long trip to Germany and Holland. I have an iPhone 4, and I only plan on bringing it to use it as a camera. I'm staying at a family members house so wifi is easy to come by. How should I set my phone so that I will not be pushed any data or will not recieve any sort of change in my bill. 
    From my understanding if i put it on airplane mode AND also turn off cellular data in the general>network>cellular data settings that I should be fine and even if someone trys to text or call it will not go through. I just want a confirmation so that nothing makes me want to cry when I come home.

    forrestp wrote:
    So in a week I leave for a month long trip to Germany and Holland. I have an iPhone 4, and I only plan on bringing it to use it as a camera. I'm staying at a family members house so wifi is easy to come by. How should I set my phone so that I will not be pushed any data or will not recieve any sort of change in my bill. 
    From my understanding if i put it on airplane mode AND also turn off cellular data in the general>network>cellular data settings that I should be fine and even if someone trys to text or call it will not go through. I just want a confirmation so that nothing makes me want to cry when I come home.
    leave the phone home, buy a camera

Maybe you are looking for

  • How do I open an illustrator file in photoshop with layers

    How do I open an illustrator file in photoshop with layers

  • Immutable String in a swing.text.Document

    Hello, I want to add to a text component an 'immutable' bit of text. That is a string that is one 'item', it can not be broken or split. If for example if you wanted to delete you would have to delete the whole thing, not part of it. Does anyone know

  • Runtime.exec - Too Many Open Files

    System version : Red Hat Enterprise Linux 2.4.21-47.ELsmp AS release 3 (Taroon Update 8) JRE version : 1.6.0-b105 Important : the commands described below are launched from a Web application : Apache Tomcat 6.0.10 Hello, I'm facing a problem already

  • Safari taking a lot of memory

    I noticed that my adobe programs were getting laggy so I checked my activity monitor and see that safari web content is taking most of the memory. Is there anything I can do to keep this from happening? I only have 5 tabs open and you can see from th

  • Can I attend Oracle 10g DBA course & attempt DBA Certification for 11g

    Hi, I am already OCP-PLSQL and want to attempt OCP-DBA stream. I enquired at various oracle education centers and came to know that all are conducting courses for Oracle-10g. So can I attend Oracle 10g DBA course (Mandatory Course) and attempt DBA Ce