i saw the docs for both .. but found the terms a bit hard to get.
i was hoping to get some simple answers here.

thanks for your time :)

Recommended Answers

All 6 Replies

PrintRequestAttributeSet is just an interface, HashPrintRequestAttributeSet is a class that implements PrintRequestAttributeSet.

so i suppose functionally they are the same ?
what is the advantage of keeping one as an interface and another as a class ? why not just keep one ?

so i suppose functionally they are the same ?

No, one's an interface, the other is a class. Definitely not the same. Start with a quick review of this tutorial: http://docs.oracle.com/javase/tutorial/java/concepts/interface.html

The advantage is that the print service needs you to suppy some attributes and by defining that as an interface it leaves you free to implement them however you want (consistent with the interface definition of course). For most applications, where there's no need to do anything special, they provide a "default" implementation of the interface in the form of the HashPrintRequestAttributeSet class that you can use without any further effort.

No, one's an interface, the other is a class.

i did get that part... , i guess the way i asked the question was pretty vauge. my bad.

For most applications, where there's no need to do anything special, they provide a "default" implementation of the interface in the form of the HashPrintRequestAttributeSet class

thanks! that makes things a lot clearer.

however , regarding the attributes , using just printDialog() without any attributes let me edit the print settings by clicking the properties button of the dialog that comes up... however , when i used the HashPrintRequestAttributeSet attribute with the printDialog, the properties button was left dysfunctional. why is that ?

this is what im doing

public void filePrint() {
        PrinterJob printer = PrinterJob.getPrinterJob();
        //HashPrintRequestAttributeSet pAttrib = new HashPrintRequestAttributeSet();// pAttrib inside printDialog() does not give functional properties button  
        if (printer.printDialog()) // without it , however , i do get a functional button for properties.
        { 
            try {
                printer.print(); 
            } catch (PrinterException e) {
                e.printStackTrace();
            }
        }
    }

Sorry, I don't know the answer to that.

ok. thanks for clearing up the main doubt :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.