Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Coding errors for printing function, please help
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Jose Argueta
Coding errors for printing function, please help
2 Answer(s)      2 years and 11 months ago
Posted in : Java Beginners


Hello, We, my classmates and I, wrote this software but I ran into problems with printing button. Can someone please take a look and help me to fix this. Although it is not actually printing the persons class schedule, we have currently coded the print button for class schedule to bring up the printer menu. I can email the program too. I am new to this site. Thanks a lot.

import java.awt.*;
import java.awt.print.*;
import javax.print.attribute.*;
import javax.swing.UIManager;

public class PrintSchedule implements Printable {


    public int print(Graphics g, PageFormat pf, int page) throws
                                                        PrinterException {

        if (page > 0) { /* We have only one page, and 'page' is zero-based */
            return NO_SUCH_PAGE;
        }

        /* User (0,0) is typically outside the imageable area, so we must
         * translate by the X and Y values in the PageFormat to avoid clipping
         */
        Graphics2D g2d = (Graphics2D)g;
        g2d.translate(pf.getImageableX(), pf.getImageableY());

        /* Now we perform our rendering */
        g.drawString("Test the print dialog!", 100, 100);

        /* tell the caller that this page is part of the printed document */
        return PAGE_EXISTS;
    }

    public static void main(String args[]) {

        try {
            String cn = UIManager.getSystemLookAndFeelClassName();
            UIManager.setLookAndFeel(cn); // Use the native L&F
        } catch (Exception cnf) {
        }
        PrinterJob job = PrinterJob.getPrinterJob();
        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
        PageFormat pf = job.pageDialog(aset);
        job.setPrintable(new PrintSchedule(), pf);
        boolean ok = job.printDialog(aset);
        if (ok) {
            try {
                 job.print(aset);
            } catch (PrinterException ex) {
             /* The job did not successfully complete */
            }
        }
        System.exit(0);
    }
}

Advertisement
View Answers

December 12, 2011 at 12:49 PM




December 18, 2011 at 6:18 AM


Thanks



Related Tutorials/Questions & Answers:
Coding errors for printing function, please help
Coding errors for printing function, please help  Hello, We, my classmates and I, wrote this software but I ran into problems with printing button. Can someone please take a look and help me to fix this. Although
need to fix errors please help
need to fix errors please help  it does have 2 errors what should i...; String name2; System.out.println("please enter your name:"); name1= input.readline(); System.out.println("please enter your friend's name:"); name2
Advertisements
Help please, some strange errors
Help please, some strange errors  Sorry about this messy formatting... is causing that run-time errors? Any kind of help will be helpful to me. and let... this errors so i have posted the whole program here. Here i tried to make the monopoly
Load function ***PLEASE HELP
Load function ***PLEASE HELP   Hi I am writing a program that tracks... function that loads a file. The save function prompts the user to enter... a load function that prompts the user for the file name to be loaded
Begineer in coding please help me
Begineer in coding please help me  I have Person class{ int pid; String Pname; //and have a Address filed of type Address not String!!! Address... address to a person object.. please help me
problem in writing coding. Please help me.
problem in writing coding. Please help me.  Hi sir, my name is Logeswaran. I have problem in writing JSP coding for my university assigments... like? I'm really stuck on this. Please help me. By the way, I'm using Access
Need urgent help with C++ errors!
Need urgent help with C++ errors!  hi, i'm new to C++ programming. this is my code... i'm using Turbo C++. It's showing so many errors!.. I don't know what to do. Please help!! #include<iostream.h> void main
Please provide the coding for this problem
Please provide the coding for this problem  Please provide the coding for the following problem. Write a "hangman" game that randomly generates a word and prompts the user to guess one letter at a time. Each letter in the word
Please help me to create this coding for pizza order application using a handheld computer.....
Please help me to create this coding for pizza order application using... in the kitchen which displays the orders to be cooked. anybody please help me... ? Lemonade RM3.80 ? Fizzy orange RM4.90 The system must contain the HELP
jsp coding please.
jsp coding please.  hi sir, my name is logeswaran. I have a problem... list. please show me how to do it? thank you. By the way, I'm using access database and coding JSP.   Follow these steps: 1)Go to the start->
Please give me coding for this..
Please give me coding for this..  Write an application that inputs one number consisting of five digits from the user.separates the number ibto its individual digits and prints the digits separated from one another by three
please help//
please help//  Number square cube 1 1 1 3 9 27 5 25 125 7 49 343 9 81 729 total 165 1225 ‚?? this is the ouput..;;; i
please help//
please help//  Number square cube 1 1 1 3 9 27 5 25 125 7 49 343 9 81 729 total 165 1225 ‚?? this is the ouput..;;; i
please help//
please help//  Number square cube 1 1 1 3 9 27 5 25 125 7 49 343 9 81 729 total 165 1225 ‚?? this is the ouput..;;; i
please help
please help  please send me the code of dynamic stack in java without using the built in functions
help please?
help please?  Define a class named Circle with the following properties: List item An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier. Both
help please?
help please?  Define a class named Circle with the following properties: ‚?Ę An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier. Both data fields
help please?
help please?  Define a class named Circle with the following properties: List item ‚?Ę An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier. Both
help please?
help please?  Define a class named Circle with the following properties: List item An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier. Both
help please?
help please?  Define a class named Circle with the following properties: List item An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier. Both
java please please help
java please please help  Dear Friends plz help me to complete this program import java.util.*; public class StringDemo { static...[] to HashMap so that i can seperate key and value using Map.Entry.Please help me!  
Please Help
Please Help  How do I create an attribute that represents the following: A grayscale ‚??color‚?? value, that is, an integer between 0 and 255 inclusive, where 0 corresponds to the darkest black and 255 to the brightest white
Please Help
Please Help  How do I create an attribute that represents the following: A grayscale 'color' value, that is, an integer between 0 and 255 inclusive, where 0 corresponds to the darkest black and 255 to the brightest white
help please?
help please?  Define a class named Circle with the following properties: ? An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier. Both data fields
Please help
Please help  Problem: Write a program that does addition, subtraction, multiplication and division operation on real numbers. The operation started with a user entered 2 numbers and click one of the operation buttons
Please help
Please help  Problem: Write a program that does addition, subtraction, multiplication and division operation on real numbers. The operation started with a user entered 2 numbers and click one of the operation buttons
help please
help please  hi i am done with register application using jsps servlets htmls. But i couldnt imp one thing that.. Wen u login to ur account browser... file.. Or atleast help me with code here.. I tried checking session alive
please help
please help  public class AllContact extends javax.swing.JFrame { /** Creates new form AllContact */ public AllContact() { initComponents(); try{ Connection1 con =new Connection1(); Connection conobj
Please provide coding for following problem
Please provide coding for following problem  Please provide the coding for the following problem: You will write a java program that will read data from a file. The data in the file will be: John Doe 75 Joe Blow 65 Mary Smith 80
need help please
enter a page second time. Please help me. By the way I'm using Access database and JSP coding Thank you...need help please  Dear sir, my name is logeswaran. I have a big
please help with the coding of this interface,i cnt seem to figure out codes for things to work here.realy nid them ASAP plz
please help with the coding of this interface,i cnt seem to figure out codes for things to work here.realy nid them ASAP plz  /* * To change...); jMenuBar1.add(jMenu4); jMenu5.setText("Help"); jMenuBar1.add(jMenu5
 

 

 

DMCA.com