This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes How to know whether a printer is switched off/disconnected Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to know whether a printer is switched off/disconnected" Watch "How to know whether a printer is switched off/disconnected" New topic
Author

How to know whether a printer is switched off/disconnected

garfild Baram
Ranch Hand

Joined: Mar 24, 2003
Posts: 60
Hi guys,
The PrintServiceLookup.lookupPrintServices method returns a list of all the installed printers. of all such installed (networked) printers how can one know whether a printer is switched off or disconnected?

my code:

public void lookupPrinter(String printerName) throws ModelException {

PrintService selectedPrintService = null;
PrintService[] services = PrintServiceLookup.lookupPrintService(DocFlavor.SERVICE_FORMATTED.PRINTABLE,null);
if(services.length>0){
int printerIndex=0;
for(int i=0; i<services.length;i++){
if (services[i].getName().equalsIgnoreCase(printerName)) {
selectedPrintService = services[i];
}
}
}


should I use PrinterState for that perpose or printerStateReason ? if so, how?

PrinterState pState = services[0].getAttribute(PrinterState.class); - Doesnt work, I get null all the time

Please advise

thanks a lot..
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8713
    
    6

I think printing is more closely related to GUI issues, so I'm going to move this post to that forum.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to know whether a printer is switched off/disconnected
 
Similar Threads
find the PrinterJobQueue in and jobsnames in queue
Cannot get shared printers description
List of Printers in client machine -Java
How to distinguish Hardware printer and Software printer
find the network printers status and job names