Monitor Print Queue with java program

I'm plan to write a client/server based application which control the printing for every user. I've no idea how to start on the application.
1. Is it possible to monitor the print queue or print job using java application?
2. How does the server react if the client sending the print job to there? How's the client can trigger the signal during printing and send to the server?
Thank you!

I'm plan to write a client/server based application
which control the printing for every user. I've no
idea how to start on the application.You should establish feasibility first, before planning to write anything
1. Is it possible to monitor the print queue or print
job using java application?Not really. Print queues are highly system-dependent things and some e.g. Windows can really only be accessed via system calls in a native language.
2. How does the server react if the client sending
the print job to there?Err, it prints the file?
How's the client can trigger the signal during printing and send to the server? What signal?
But I suspect the answer to the first question makes the others irrelevant.

Similar Messages

  • Possible to Get Database backup with java program

    Hello
    Is it possible to Get or Create Database Backup on runtime with java program using some sql statements
    How could i do that
    '

    Cross posted and multi-posted.
    Hey jackass why don't you look where I already answered this question.
    http://forum.java.sun.com/thread.jspa?threadID=654902&messageID=3849575

  • How to share 10.6 OSX Server print queue with Windows 7 successfully?

    I used Bonjour Print Services for a Windows 7 machine (http://support.apple.com/kb/dl999) to successfully connect to a Mac OX Server 10.6 print queue, and the following message is generated in the print log and CUPS log,
    "POST/printers/stormoncecar/ HTTP/ 1.1" 200 2205 Print-Job Successful-OK
    There are no errors, however, nothing comes out of the printer.  It works for all the Mac OS Client machines, but not for any of the Windows 7 machines.
    How to share print queue with Windows 7 successfully?

    I'm back on this problem.  I thought I would give more details as I still can't print. 
    Operating System: 10.6.8
    Driver for Canon LBP6750 UFRII prints from Mac and prints from Windows 7.  However, printing from Windows 7 as you share the printer from your Mac does not print out anything and has no errors.
    JOB INFO
    Completed smbprn.00000004 Microsoft Word - Document 1 3:43PM Today 3:43PM Name
    CUPS > access_log
    localhost - - [01/Feb/2012:15:43:33 +0900] "POST /printers/FLOOD_6750_UFR HTTP/1.1" 401 2003 Print-Job successful-ok
    localhost - lino [01/Feb/2012:15:43:33 +0900] "POST /printers/FLOOD_6750_UFR HTTP/1.1" 200 2003 Print-Job successful-ok
    CONSOLE MESSAGES
    2/1/12 3:47:45 PM    com.apple.launchd.peruser.501[
    200]    (jp.co.canon.UFR2.BackGrounder[664]) posix_spawn("/Library/Printers/Canon/UFR2/Utilities/UFR II BackGrounder.app/Contents/MacOS/UFR II BackGrounder", ...): No such file or directory

  • How to run sscript shell with java program

    Hi everybody,
    i want to know how can i do to execute a script shelle (bash) with program java (if it s possible)
    for example this script:
    #!/bin/bash
    echo "hello"
    can i run it with java program or i have to make dome modifications .
    thank you for your help in advance.

    Well, if you want to be portable across platforms, you should write as much code in Java as possible and not rely on native scripts (I'm sure your script is more complex than this 'echo' example ;-) ).
    Having said that, you can use the java.lang.Runtime class and in particular its various exec() methods.
    Try something like this:
    Process p;
    try {
        p = Runtime.getRuntime().exec("myscript.sh");
    } catch (IOException ioe) {
    }You can then "interact" with the spawned process with the Process object returned by the exec method.
    Note you need to have the appropriate security rights.
    For more details, look at the API documentation here:
    http://java.sun.com/j2se/1.4.2/docs/api/
    hth,
    -Alexis

  • Please help with Java program

    Errors driving me crazy! although compiles fine
    I am working on a project for an online class - I am teaching myself really! My last assignment I cannot get to work. I had a friend who "knows" what he is doing help me. Well that didn't work out too well, my class is a beginner and he put stuff in that I never used yet. I am using Jgrasp and Eclipse. I really am trying but, there really is no teacher with this online class. I can't get questions answered in time and stuff goes past due. I am getting this error:
    Exception in thread "main" java.lang.NullPointerException
    at java.io.Reader.<init>(Reader.java:61)
    at java.io.InputStreamReader.<init>(InputStreamReader .java:55)
    at java.util.Scanner.<init>(Scanner.java:590)
    at ttest.main(ttest.java:54)
    ----jGRASP wedge2: exit code for process is 1.
    ----jGRASP: operation complete.
    This is my code:
    import java.util.*;
    import java.io.*;
    public class ttest
    static Scanner console = new Scanner(System.in);
    public static void main(String[] args)throws IOException
    FileInputStream fin = null; // input file reference
    PrintStream floser = null; // output file references
    PrintStream fwinner = null;
    Scanner rs; // record scanner
    Scanner ls; // line scanner
    String inputrec; // full record buffer
    int wins; // data read from each record
    int losses;
    double pctg;
    String team;
    String best = null; // track best/worst team(s)
    String worst = null;
    double worst_pctg = 2.0; // track best/worst pctgs
    double best_pctg = -1.0;
    int winner_count = 0; // counters for winning/losing records
    int loser_count = 0;
    // should check args.length and if not == 1 generate error
    try
    Scanner inFile = new Scanner(new FileReader("football.txt"));
    catch( FileNotFoundException e )
    System.exit( 1 );
    try
    floser = new PrintStream( new FileOutputStream( "loser.txt" ) );
    fwinner = new PrintStream( new FileOutputStream( "winner.txt" ) );
    catch( FileNotFoundException e )
    System.out.printf( "unable to open an output file: %s\n", e.toString() );
    System.exit( 1 );
    try
    rs = new Scanner( fin );
    while( rs.hasNext( ) )
    inputrec = rs.nextLine( ); /* read next line */
    ls = new Scanner( inputrec ); /* prevents stumble if record has more than expected */
    team = ls.next( );
    wins = ls.nextInt();
    losses = ls.nextInt();
    if( wins + losses > 0 )
    pctg = ((double) wins)/(wins + losses);
    else
    pctg = 0.0;
    if( pctg > .5 )
    if( pctg > best_pctg )
    best_pctg = pctg;
    best = team;
    else
    if( pctg == best_pctg )
    best += ", " + team;
    fwinner.printf( "%10s %2d %2d %5.3f\n", team, wins, losses, pctg );
    winner_count++;
    else
    if( pctg < worst_pctg )
    worst_pctg = pctg;
    worst = team;
    else
    if( pctg == worst_pctg )
    worst += ", " + team;
    floser.printf( "%10s %2d %2d %5.3f\n", team, wins, losses, pctg );
    loser_count++;
    fin.close( );
    floser.close( );
    fwinner.close( );
    catch( IOException e ) {
    System.out.printf( "I/O error: %s\n", e.toString() );
    System.exit( 1 );
    System.out.printf( "%d teams have winning records; %d teams have losing records\n", winner_count, loser_count );
    System.out.printf( "Team(s) with best percentage: %5.3f %s\n", best_pctg, best );
    System.out.printf( "Team(s) with worst percentage: %5.3f %s\n", worst_pctg, worst );
    The assignment is:
    Create a Java program to read in an unknown number of lines from a data file. You will need to create the data file. The contents of the file can be found at the bottom of this document. This file contains a football team's name, the number of games they have won, and the number of games they have lost.
    Your program should accomplish the following tasks:
    1. Process all data until it reaches the end-of-file. Calculate the win percentage for each team.
    2. Output to a file ("top.txt") a listing of all teams with a win percentage greater than .500. This file should contain the team name and the win percentage.
    3. Output to a file ("bottom.txt") a listing of all teams with a win percentage of .500 or lower. This file should contain the team name and the win percentage.
    4. Count and print to the screen the number of teams with a record greater then .500 and the number of teams with a record of .500 and below, each appropriately labeled.
    5. Output in a message box: the team with the highest win percentage and the team with the lowest win percentage, each appropriately labeled. If there is a tie for the highest win percentage or a tie for the lowest win percentage, you must output all of the teams.
    Dallas 5 2
    Philadelphia 4 3
    Washington 3 4
    NY_Giants 3 4
    Minnesota 6 1
    Green_Bay 3 4

    import java.util.*;
    import java.io.*;
    public class ttest
    static Scanner console = new Scanner(System.in);
    public static void main(String[] args)throws IOException
    FileInputStream fin = null; // input file reference
    PrintStream floser = null; // output file references
    PrintStream fwinner = null;
    Scanner rs; // record scanner
    Scanner ls; // line scanner
    String inputrec; // full record buffer
    int wins; // data read from each record
    int losses;
    double pctg;
    String team;
    String best = null; // track best/worst team(s)
    String worst = null;
    double worst_pctg = 2.0; // track best/worst pctgs
    double best_pctg = -1.0;
    int winner_count = 0; // counters for winning/losing records
    int loser_count = 0;
    // should check args.length and if not == 1 generate error
    try
    Scanner inFile = new Scanner(new FileReader("football.txt"));
    catch( FileNotFoundException e )
    System.exit( 1 );
    try
    floser = new PrintStream( new FileOutputStream( "loser.txt" ) );
    fwinner = new PrintStream( new FileOutputStream( "winner.txt" ) );
    catch( FileNotFoundException e )
    System.out.printf( "unable to open an output file: %s\n", e.toString() );
    System.exit( 1 );
    try
    rs = new Scanner( fin );
    while( rs.hasNext( ) )
    inputrec = rs.nextLine( ); /* read next line */
    ls = new Scanner( inputrec ); /* prevents stumble if record has more than expected */
    team = ls.next( );
    wins = ls.nextInt();
    losses = ls.nextInt();
    if( wins + losses > 0 )
    pctg = ((double) wins)/(wins + losses);
    else
    pctg = 0.0;
    if( pctg > .5 )
    if( pctg > best_pctg )
    best_pctg = pctg;
    best = team;
    else
    if( pctg == best_pctg )
    best += ", " + team;
    fwinner.printf( "%10s %2d %2d %5.3f\n", team, wins, losses, pctg );
    winner_count++;
    else
    if( pctg < worst_pctg )
    worst_pctg = pctg;
    worst = team;
    else
    if( pctg == worst_pctg )
    worst += ", " + team;
    floser.printf( "%10s %2d %2d %5.3f\n", team, wins, losses, pctg );
    loser_count++;
    fin.close( );
    floser.close( );
    fwinner.close( );
    catch( IOException e ) {
    System.out.printf( "I/O error: %s\n", e.toString() );
    System.exit( 1 );
    System.out.printf( "%d teams have winning records; %d teams have losing records\n", winner_count, loser_count );
    System.out.printf( "Team(s) with best percentage: %5.3f %s\n", best_pctg, best );
    System.out.printf( "Team(s) with worst percentage: %5.3f %s\n", worst_pctg, worst );
    }

  • To generate a wsdl using JAX-WS in JBOSS with java program but without EJB

    Hi,
    I am using JAX-WS to generate webservices using JBOSS application server by writing a java program.
    My sample java program includes :which takes an i/p name as string and displays out put as "Hello name",with the use of annotations.And,also have written web.xml for it.If I start JBOSS without adding project to it,it is starting.BUt If I add project to it the server is not publishing.Its getting like:"publishing JBOSS 4.2.2....:waiting for virtual machine to exit".
    I have followed the link:*http://www.javabeat.net/articles/2007/10/creating-webservice-using-jboss-and-eclipse/3*
    to do this,where in it was given that by means of auto build process of eclipse IDE war file generates in default jboss folder.But which is not happening,so that,am unable to generate wsdl file..
    Can any body help me?
    1) why jboss is not publishing after adding project to it?
    2) why war file is not generating in the default jboss folder?
    Regards....

    Yeah sure!!
    Overall picture: I wish to expose my OSB services to the third parties using OCSG. For that I've created the Communication services corresponding to each OSB service.
    Problem: Integration with the OSB.
    At the OSB side I've got JMS queues which interacts with other existing systems in my SOA enviornment. But I'm not getting how to get the OCSG application- triggered request messages in that queue? Please help.
    Also I've read about the SOA facades for integration with OSB.Which of the two approaches you will suggest?

  • Help with Java programming project

    Hi,
    I need help in writing this Java program. The purpose of this program is to read a variable-length stream of 0, 1 characters from an input text file (call it input.txt) one character at a time, and generate the corresponding B8ZS output stream consisting of the +, - , and 0 characters (with appropriate substitutions) one-character-at-a-time into a text file (called output.txt).
    The program must use a class called AMIConverter with an object called AMI . Class AMIConverter must have a method called convert which converts an individual input character 0 or 1 into the appropriate character 0 or + or - of AMI.
    It first copy the line to file output.txt. Then read the line one character at a time and pass only valid characters (0 or 1) to AMI.convert, which assumes only valid characters. The first 1 in each new 'Example' should be converted to a +.
    This is what is read in, but this is just a test case.
    0101<1000
    1100a1000b00
    1201g101
    should now produce two lines of output for each 'Example', as shown below:
    This should be the output of the output.txt file
    Example 1
    in :0101<1000
    out:0+0-+000
    Example 2
    in :1100a1000b00
    out:+-00+00000
    Example 3
    in :1201g101
    out:+0-+0-
    To elaborate more, only 1 and 0 are passed to "convert" method. All others are ignored. 0 become 0 and 1 become either + or - and the first "1" in each new example should be a +.
    This is what I have so far. So far I am not able to get the "in" part, the characters (e.g. : 0101<1000 ) out to the output.txt file. I am only able to get the "out" part. And I also can't get it to display a + for the first "1" in each new examples.
    import java.io.*;
    public class AMIConverter
         public static void main (String [] args) throws IOException
              AMI ami = new AMI();
              try
                   int ch = ' ';
                   int lineNum = 1;
         int THE_CHAR_0 = '0';
         int THE_CHAR_1 = '1';
                   BufferedReader infile = new BufferedReader(new FileReader("input.txt"));
         PrintWriter outfile = new PrintWriter("output.txt");
         outfile.write("Example " + lineNum);//prints Example 1
         outfile.println();
         outfile.write("in :");
    outfile.println();
    outfile.write("out:");
         while ((ch = infile.read()) != -1)
         if (ch == '\r' || ch == '\n')
              lineNum++;
              outfile.println();
              outfile.println();
              outfile.write("Example " + lineNum);
              outfile.println();
              outfile.write("in :");
              outfile.println();
              outfile.write("out:");
         else
         if (ch == THE_CHAR_0)
              int output = ami.convert(ch);
              outfile.write(output);
         else     
         if (ch == THE_CHAR_1)
              int output = ami.convert(ch);
              outfile.write(output);          
    }//end while
         infile.close();
         outfile.close();
         }catch (IOException ex) {}
    }//main method
    }//class AMIConverter
    This is my AMI class
    import java.io.*;
    public class AMI
         int THE_CHAR_0 = '0';
    int THE_CHAR_1 = '1';
    int total = '+';
    int minus = '-';
    int count = 0;
    public int convert(int ch)
         try
              PrintWriter outfile = new PrintWriter("output.txt");
              if (ch == THE_CHAR_0)
         return ch;
         else
         if (ch == THE_CHAR_1)
         count++;
         if (count%2 == 1)
              ch = total;
              return (ch);
         else
                             ch = minus;     
                             return (ch);      
    }catch (FileNotFoundException e) {}      
         return ch;
    }//method convert
    }//class AMI
    Any help would be appreicated.
    Thanks!

    Hi,
    I need help in writing this Java program. The purpose of this program is to read a variable-length stream of 0, 1 characters from an input text file (call it input.txt) one character at a time, and generate the corresponding B8ZS output stream consisting of the +, - , and 0 characters (with appropriate substitutions) one-character-at-a-time into a text file (called output.txt).
    The program must use a class called AMIConverter with an object called AMI . Class AMIConverter must have a method called convert which converts an individual input character 0 or 1 into the appropriate character 0 or + or - of AMI.
    It first copy the line to file output.txt. Then read the line one character at a time and pass only valid characters (0 or 1) to AMI.convert, which assumes only valid characters. The first 1 in each new 'Example' should be converted to a +.
    This is what is read in, but this is just a test case.
    0101<1000
    1100a1000b00
    1201g101
    should now produce two lines of output for each 'Example', as shown below:
    This should be the output of the output.txt file
    Example 1
    in :0101<1000
    out:0+0-+000
    Example 2
    in :1100a1000b00
    out:+-00+00000
    Example 3
    in :1201g101
    out:+0-+0-
    To elaborate more, only 1 and 0 are passed to "convert" method. All others are ignored. 0 become 0 and 1 become either + or - and the first "1" in each new example should be a +.
    This is what I have so far. So far I am not able to get the "in" part, the characters (e.g. : 0101<1000 ) out to the output.txt file. I am only able to get the "out" part. And I also can't get it to display a + for the first "1" in each new examples.
    import java.io.*;
    public class AMIConverter
    public static void main (String [] args) throws IOException
    AMI ami = new AMI();
    try
    int ch = ' ';
    int lineNum = 1;
    int THE_CHAR_0 = '0';
    int THE_CHAR_1 = '1';
    BufferedReader infile = new BufferedReader(new FileReader("input.txt"));
    PrintWriter outfile = new PrintWriter("output.txt");
    outfile.write("Example " + lineNum);//prints Example 1
    outfile.println();
    outfile.write("in :");
    outfile.println();
    outfile.write("out:");
    while ((ch = infile.read()) != -1)
    if (ch == '\r' || ch == '\n')
    lineNum++;
    outfile.println();
    outfile.println();
    outfile.write("Example " + lineNum);
    outfile.println();
    outfile.write("in :");
    outfile.println();
    outfile.write("out:");
    else
    if (ch == THE_CHAR_0)
    int output = ami.convert(ch);
    outfile.write(output);
    else
    if (ch == THE_CHAR_1)
    int output = ami.convert(ch);
    outfile.write(output);
    }//end while
    infile.close();
    outfile.close();
    }catch (IOException ex) {}
    }//main method
    }//class AMIConverterThis is my AMI class
    import java.io.*;
    public class AMI
    int THE_CHAR_0 = '0';
    int THE_CHAR_1 = '1';
    int total = '+';
    int minus = '-';
    int count = 0;
    public int convert(int ch)
    try
    PrintWriter outfile = new PrintWriter("output.txt");
    if (ch == THE_CHAR_0)
    return ch;
    else
    if (ch == THE_CHAR_1)
    count++;
    if (count%2 == 1)
    ch = total;
    return (ch);
    else
    ch = minus;
    return (ch);
    }catch (FileNotFoundException e) {}
    return ch;
    }//method convert
    }//class AMIAny help would be appreicated.
    Thanks!

  • Monitor print queue for job size

    Hi,
    Problem: Occasionally, some print queues are found with a job that is spooling uncontrolled. Job will reach 2/3GB which will cause services to under perform and sometimes crash.
    We are looking at understanding the reason why the file is spooling uncontrolled. I believe it is something to do with the fact some of the users are roaming users and when moving site, when arriving to a new site they should get the correct printers for
    that site. It is happening that this is not being applied so they print to the printer on the previous site where they were, which seems to cause this behavior.... anyway.. I do not have any more logic details around this.. still exploring..
    The question today is, can I set some sort of monitoring on the local print server to alert me when a job on any print queue has reached a specific size?
    Or perhaps delete the job automatically if it does reach this threshold.
    Thank you

    On Server 2012 use the powershell commands included with the product.  For 2008R2 and prior use the WMI Interfaces and the scripts included with the OS
    prnjobs.vbs to list job size and ID, then when the size is excessive the same script is used to delete the job.
    This information at the scripting center looks like what you wish to accomplish
    https://gallery.technet.microsoft.com/scriptcenter/9b07ec17-a3ae-427d-a417-c95f05fc515f
    Alan Morris formerly with Windows Printing Team

  • Purge a queue with JAVA API

    Hi,
    Is it possible to purge a queue with the JAVA API ?
    I have not found anything ...
    I am also trying to browse archived messages (state 2), the "browseQueue" method does only browse the ready messages (state 0).
    Is it possible to browse archived messages ?? (in java)
    Thanks in advance.

    found it, I had to write
    "ormi://<some-ip>:12401/orabpel" for java.naming.provider.url

  • Printing HTML with Java Printing Service(JDK1.4 beta)

    Hi there!
    I'm currently checking out the new Java Printing Service (JPS) in the new JDK1.4 beta. This looks like a very promising printing API, with amongst others printer discovery and support for MIME types - but I have some problems with printing HTML displayed in a JEditorPane.
    I'm developing an application that should let the user edit a (HTML)document displayed in a JEditorPane and the print this document to a printer. I have understood that this should be peace-of-cake using the JPS which has pre-defined HTML DocFlavor amongst others, in fact here is what Eric Armstrong says on Javaworld (http://www.javaworld.com/javaone01/j1-01-coolapis.html):
    "With JPS, data formats are specified using MIME types, for example: image/jpeg, text/plain, and text/html. Even better, the API includes a formatting engine that understands HTML, and an engine that, given a document that implements the Printable or Pageable interface, generates PostScript. The HTML formatting engine looks particularly valuable given the prevalence of XML data storage. You only need to set up an XSLT (eXtensible Stylesheet Language Transformation) stylesheet, use it to convert the XML data to HTML, and send the result to the printer."
    After one week of reasearch I have not been able to do what Armstrong describes; print a String that contains text of MIME type text/html.
    I have checked the supported MIMI types of the Print Service returned by PrintServiceLookup.lookupDefaultPrintService(). This is the result:
    DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    aset.add(MediaSizeName.ISO_A4);
    aset.add(new Copies(2));
    PrintService[] service = PrintServiceLookup.lookupPrintServices(flavor,aset);
    if (service.length > 0) {
    System.out.println("Selected printer " + service[0].getName());
    DocFlavor[] flavors = service[0].getSupportedDocFlavors();
    for (int i = 0;i<flavors.length;i++) {
    System.out.println("Flavor "+i+": "+flavors.toString());
    Selected printer \\MUNIN-SERVER\HP LaserJet 2100 Series PCL 6
    Flavor 0: image/gif; class="[B"
    Flavor 1: image/gif; class="java.io.InputStream"
    Flavor 2: image/gif; class="java.net.URL"
    Flavor 3: image/jpeg; class="[B"
    Flavor 4: image/jpeg; class="java.io.InputStream"
    Flavor 5: image/jpeg; class="java.net.URL"
    Flavor 6: image/png; class="[B"
    Flavor 7: image/png; class="java.io.InputStream"
    Flavor 8: image/png; class="java.net.URL"
    Flavor 9: application/x-java-jvm-local-objectref; class="java.awt.print.Pageable"
    Flavor 10: application/x-java-jvm-local-objectref; class="java.awt.print.Printable"
    As you can see there is no support for text/html here.
    If anyone has a clue to what I'm missing here or any other (elegant, simple) way to print the contents of a JEditorPane, please speak up!
    Reply to: [email protected] or [email protected] or here in this forum

    Since you have 'printable' as one of your flavors, try this using a JTextPane (assuming you can dump your HTML into a JTextPane, which shouldn't be a big problem)...
    1. Have your JTextPane implement Printable
    ie. something like this:
    public class FormattedDocument extends JTextPane implements Printable 2. Read your HTML into the associated doc in the text pane.
    3. Implement the printable interface, since you have it as one of your available flavors (I'd imagine everybody has printable in their available flavors). Something like this:
    public int print(Graphics g, PageFormat pf, int pageIndex) {
            Graphics2D g2 = (Graphics2D) g;
            g2.translate((int)pf.getImageableX(), (int)pf.getImageableY());
            g2.setClip(0, 0, (int)pf.getImageableWidth(), (int)pf.getImageableHeight()); 
            if (pageIndex == 0)
                setupPrintView(pf);
            if (!pv.paintPage(g2, pageIndex))
                return NO_SUCH_PAGE;
            return PAGE_EXISTS;
        }Here's my setupPrintView function, which is executed once on page 0 (which still needs some polishing in case I want to start from page 5). It sets up a 'print view' class based on the root view of the document. PrintView class follows...
    public void setupPrintView(PageFormat pf) {
    View root = this.getUI().getRootView(this);
            pv = new PrintView(this.getStyledDocument().getDefaultRootElement(), root,
                               (int)pf.getImageableWidth(), (int)pf.getImageableHeight());Note of obvious: 'pv' is of type PrintView.
    Here's my PrintView class that paints your text pane line by line, a page at a time, until there is no more.
    class PrintView extends BoxView
        public PrintView(Element elem, View root, int w, int h) {
            super(elem, Y_AXIS);
            setParent(root);
            setSize(w, h);
            layout(w, h);
        public boolean paintPage(Graphics2D g2, int pageIndex) {
            int viewIndex = getTopOfViewIndex(pageIndex);
            if (viewIndex == -1) return false;
            int maxY = getHeight();
            Rectangle rc = new Rectangle();
            int fillCounter = 0;
            int Ytotal = 0;
            for (int k = viewIndex; k < getViewCount(); k++) {
                rc.x = 0;
                rc.y = Ytotal;
                rc.width = getSpan(X_AXIS, k);
                rc.height = getSpan(Y_AXIS, k);
                if (Ytotal + getSpan(Y_AXIS, k) > maxY) break;
                paintChild(g2, rc, k);
                Ytotal += getSpan(Y_AXIS, k);
            return true;
    // find top of page for a given page number
        private int getTopOfViewIndex(int pageNumber) {
            int pageHeight = getHeight() * pageNumber;
            for (int k = 0; k < getViewCount(); k++)
                if (getOffset(Y_AXIS, k) >= pageHeight) return k;
            return -1;
    }That's my 2 cents. Any questions?

  • Changeing preferences on network printer queue with Powershell

    Hi,
    I found a script on this page - http://gallery.technet.microsoft.com/scriptcenter/878e6bac-e2a1-4502-9333-5b1420f8b957 - that I am trying to adapt to work on my users computers and not only on servers. But I can't seem to figure out how to get a reference
    to the network attached printers and change their preferences on the computer, the script only get the local ones.
    The goal is to use only a portion of the script as a logon script for some users that need onesided printing as default.
    param ($ChangeProp)
    $host.Runspace.ThreadOptions = "ReuseThread"
    Add-Type -AssemblyName System.Printing
    $permissions = [System.Printing.PrintSystemDesiredAccess]::AdministrateServer
    $queueperms = [System.Printing.PrintSystemDesiredAccess]::AdministratePrinter
    $server = new-object System.Printing.PrintServer -argumentList $permissions
    $queues = $server.GetPrintQueues()
    function SetProp($capability, $property, $enumeration)
    if ($PrintCaps.$capability.Contains($property))
    $q2.DefaultPrintTicket.$enumeration = $property
    $q2.commit()
    write-host ($q.Name +" is now configured for " + $property)
    write-host (" ")
    else
    write-host ($q.Name +" does not support " + $property)
    write-host (" ")
    try {
    foreach ($q in $queues)
    #Get edit Permissions on the Queue
    $q2 = new-object System.Printing.PrintQueue -argumentList $server,$q.Name,1,$queueperms
    # Get Capabilities Object for the Print Queue
    $PrintCaps = $q2.GetPrintCapabilities()
    switch ($ChangeProp)
    {$_ -eq "twosided"}
    SetProp DuplexingCapability TwoSidedLongEdge Duplexing
    break
    {$_ -eq "onesided"}
    SetProp DuplexingCapability onesided Duplexing
    break
    {$_ -eq "mono"}
    SetProp OutputColorCapability monochrome OutputColor
    break
    {$_ -eq "color"}
    SetProp OutputColorCapability color OutputColor
    break
    {$_ -eq "staple"}
    SetProp StaplingCapability StapleTopLeft Stapling
    break
    {$_ -eq "show"}
    $DefaultTicket = $q2.DefaultPrintTicket
    $TicketProps = $DefaultTicket | Get-Member -MemberType Property
    write-host (" ")
    write-host ($q.name)
    foreach ($p in $TicketProps)
    $PName = $p.name
    $PropValue = $DefaultTicket.$PName
    write-host ($p.name + " = " + $PropValue)
    default
    Write-Host ("$_ is not a valid parameter")
    exit
    catch [System.Management.Automation.RuntimeException]
    write-host ("Exception: " + $_.Exception.GetType().FullName)
    write-host $_.Exception.Message

    Ok, I want to run this (some...) script on a users computer, not on a server, to be able to change their printer preferences. In this case, a network attached printer with duplex default from the server would get simplex as default.
    We don't want to set up different queues on the server for different default settings. That's why we are trying with a script.
    Running your script against my computer gets me (trimmed down a bit):
    Get-ServerQueues -server it228d
    InPartialTrust : False
    ClientPrintSchemaVersion : 1
    IsXpsDevice :
    IsPublished : False
    IsRawOnlyEnabled : False
    IsBidiEnabled : False
    ScheduleCompletedJobsFirst : True
    KeepPrintedJobs : False
    IsDevQueryEnabled : False
    IsHidden : False
    IsShared : False
    IsDirect : False
    IsQueued : False
    QueueAttributes : 528
    QueueStatus :
    FullName : \\it228d\Skicka till OneNote 2010
    HostingPrintServer : System.Printing.PrintServer
    QueuePrintProcessor : System.Printing.PrintProcessor
    QueuePort : System.Printing.PrintPort
    QueueDriver : System.Printing.PrintDriver
    DefaultPrintTicket :
    UserPrintTicket :
    SeparatorFile :
    Description : \\it228d\Skicka till OneNote 2010,Send To Microsoft OneNote 2010 Driv
    er,
    Location :
    Comment :
    ShareName :
    NumberOfJobs :
    AveragePagesPerMinute :
    UntilTimeOfDay : 60
    StartTimeOfDay : 60
    DefaultPriority :
    Name : Skicka till OneNote 2010
    Priority : 1
    CurrentJobSettings :
    PrintingIsCancelled : False
    Parent :
    PropertiesCollection : {UserPrintTicket, IsXpsEnabled, Description, Name...}
    InPartialTrust : False
    ClientPrintSchemaVersion : 1
    IsXpsDevice : False
    IsPublished : False
    HasToner : True
    IsTonerLow : False
    IsWarmingUp : False
    IsInitializing : False
    IsProcessing : False
    IsWaiting : False
    IsNotAvailable : False
    IsOutputBinFull : False
    IsPrinting : False
    IsBusy : False
    IsIOActive : False
    IsOffline : False
    HasPaperProblem : False
    IsManualFeedRequired : False
    IsOutOfPaper : False
    IsPaperJammed : False
    IsPendingDeletion : False
    IsInError : False
    IsPaused : False
    QueueAttributes : 16
    QueueStatus : None
    FullName : \\it228d\PDFCreator
    HostingPrintServer : System.Printing.PrintServer
    QueuePrintProcessor : System.Printing.PrintProcessor
    QueuePort : System.Printing.PrintPort
    QueueDriver : System.Printing.PrintDriver
    DefaultPrintTicket : System.Printing.PrintTicket
    UserPrintTicket : System.Printing.PrintTicket
    SeparatorFile :
    Description : \\it228d\PDFCreator,PDFCreator,
    Location :
    Comment : eDoc Printer
    ShareName : PDFCreator
    NumberOfJobs : 0
    AveragePagesPerMinute : 0
    UntilTimeOfDay : 60
    StartTimeOfDay : 60
    DefaultPriority : 1
    Name : PDFCreator
    Priority : 1
    CurrentJobSettings : System.Printing.PrintJobSettings
    PrintingIsCancelled : False
    Parent :
    PropertiesCollection : {UserPrintTicket, IsXpsEnabled, Description, Name...}
    InPartialTrust : False
    ClientPrintSchemaVersion : 1
    IsXpsDevice : False
    IsPublished : False
    IsRawOnlyEnabled : False
    IsBidiEnabled : False
    ScheduleCompletedJobsFirst : True
    KeepPrintedJobs : False
    IsDevQueryEnabled : False
    IsPendingDeletion : False
    IsInError : False
    IsPaused : False
    QueueAttributes : 528
    QueueStatus : None
    FullName : \\it228d\Microsoft XPS Document Writer
    HostingPrintServer : System.Printing.PrintServer
    QueuePrintProcessor : System.Printing.PrintProcessor
    QueuePort : System.Printing.PrintPort
    QueueDriver : System.Printing.PrintDriver
    DefaultPrintTicket : System.Printing.PrintTicket
    UserPrintTicket : System.Printing.PrintTicket
    SeparatorFile :
    Description : \\it228d\Microsoft XPS Document Writer,Microsoft XPS Document Writer,
    Location :
    Comment :
    ShareName :
    NumberOfJobs : 0
    AveragePagesPerMinute : 0
    UntilTimeOfDay : 60
    StartTimeOfDay : 60
    DefaultPriority : 0
    Name : Microsoft XPS Document Writer
    Priority : 1
    CurrentJobSettings : System.Printing.PrintJobSettings
    PrintingIsCancelled : False
    Parent :
    PropertiesCollection : {UserPrintTicket, IsXpsEnabled, Description, Name...}
    But on my computer I have four network printers that is not listed. And those are the ones I want to change the preferences on. Is there a way to do this?

  • Need help with Java programming installation question

    Sorry for my lack of knowledge about Java programming, but:....
    A while back I thought I had updated my Java Runtime Environment programming. But I now apparently have two programs installed, perhaps through my not handling the installation properly. Those are:
    J2SE Runtime Environment 5.0 update 5.0 (a 118MB file)
    and:
    Java 2 Runtime Environment, SE v 1.4.2_05 (a 108MB file)
    Do I need both of these installed? If not, which should I uninstall?
    Or, should I just leave it alone, and not worry about it?
    Yeah, I don't have much in the way of technical knowledge...
    Any help or advice would be appreciated. Thank you.
    Bob VanHorst

    Thanks for the feedback. I think I'll do just that. Once in a while I have a problem with Java not bringing up a webcam shot, but when that happens, it seems to be more website based than a general condition.

  • Monitor Print Queue

    What would be the best way to monitor print jobs, and pause them? After pausing them I want to ask for user credentials before resuming the print job.
    Brandon Donnelson
    print-track.sourceforge.net

    Something in one of the native programming languages on the operating system you had in mind.

  • Print documents using java program.

    Java program printing documents in a printer.
    I want to do this in applet..
    but for the time being can atleast a java program do this???

    Of course it can.
    http://www.google.com/search?q=java+printing+tutorial

  • How to run native program with Java program?

    Hello
    I've got following problem. I'd like to write file browser which would work for Linux and
    Windows. Most of this program would be independent of the system but running programs not. How to run Linux program from Java program (or applet) and how to do it in Windows?.
    Cheers

    Try this:
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec("ls -l");
    InputStream stream = proc.getInputStream();
    InputStreamReader isr = new InputStreamReader(stream);
    BufferedReader br = new BufferedReader(isr);
    String line = null;
    while ( (line = br.readLine()) != null) .....
    "if the program you launch produces output or expects input, ensure that you process the input and output streams" (http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html)

Maybe you are looking for