Results 1 to 5 of 5
  1. #1
    priyaa is offline Member
    Join Date
    Aug 2010
    Posts
    4
    Rep Power
    0

    Default java 6 focus issue

    Hi all, i have a issue with java 6. after displaying printdialog and clicking 'ok' or cancel, doesnt return focus to the application. the application focus is lost. how to solve this issue?

    The part of the code i am attaching here

    public void printDrLicBondCardRtnEnvelopes()
    {
    new Thread()
    {
    public void run()
    {
    printEnvelopes();
    }
    }.start();
    }

    public void printEnvelopes()
    {
    int[] selectedRows = frame.table.getSelectedRows();
    if(selectedRows.length == 0)
    {
    JOptionPane.showMessageDialog(null, "Select rows for printing labels.",
    "Print Labels", JOptionPane.INFORMATION_MESSAGE);
    return;
    }

    //NMM(07/21/2008)
    if(isSelectedEnvelopesPrinted())
    {
    String allOrSome = allSelectedEnvelopesPrinted() ? "all" : "some";
    int status = JOptionPane.showConfirmDialog(null,
    "Envelope(s) printed on " + allOrSome + " selected row(s)" +
    "\n Print envelope(s) again?",
    "Envelope Print status", JOptionPane.YES_NO_OPTION);
    if(status == JOptionPane.NO_OPTION)
    return;
    }
    //NMM END
    addCasesToLabels();
    if(addressMap.size() == 0)
    {
    frame.addMessage("No records available for printing labels");
    return;
    }

    if(addressMap.size() > 0)
    {
    int noOfPages = addressMap.size();
    printer = (profile.isSuperUser() || profile.hasToken(PRINTER_NAME_TOKEN)) ?
    promptPrinters(noOfPages) : null;
    if(requestCancelled)
    {
    frame.addMessage("Printing cancelled...");
    return;
    }

    formatEnvelopes("MAILPAY ADDRESS ENVELOP", addressMap, printer);
    //updatePrintedLabelsStatus();



    frame.toFront();
    updatePrintedEnvelopeStatus();
    refresh();
    }
    }

    public void formatEnvelopes(String reportName, TreeMap data, String printer)
    {
    int pageNo = 0;
    ReportRequest request = createReportRequest(reportName, printer);

    ReportFreeFlowBuilder builder = loadFreeFlowReportBuilder(request,
    pageNo + 1);

    builder.initFirstPage();

    PrinterJob job = PrinterJob.getPrinterJob();
    ProgressDialog dialog = getProgressDialog("Printing DrLic/BondCard Return Envelops");
    dialog.setVisible(true);
    String id1;
    Vector v1;
    Font font = new Font("Monospaced", Font.PLAIN, 10);
    Font font8 = new Font("Monospaced", Font.PLAIN, 8);

    Address addr1 = null;
    String name1 = null;
    int rowsProcessed = 0;
    int totalRows = data.size();
    Book book = new Book();
    for (Iterator i = data.entrySet().iterator(); i.hasNext();)
    {
    id1 = (String) ((Map.Entry) i.next()).getKey();
    v1 = (Vector) data.get(id1);
    dialog.getProgressBar()
    .setValue(
    dialog.getProgressBar().getValue()
    + (++rowsProcessed
    * dialog.getProgressBar()
    .getMaximum() / totalRows));

    name1 = (String) v1.firstElement();
    addr1 = (Address) v1.lastElement();
    String line1 = getFillString(2) + id1;
    String line2 = getFillString(X_ENV) + formatName(name1);
    String line3 = getFillString(X_ENV) + formatAddrLine1(addr1);
    String line4 = getFillString(X_ENV) + formatAddrLine2(addr1);
    String line5 = getFillString(X_ENV) + formatCityStateZip(addr1);
    builder.startNewPage();
    builder.addData(new PageElement(DATA, "\n\n", LEFT, font8));
    builder.addData(new PageElement(DATA, line1, LEFT, font));
    for (int j = 0; j < 7; j++)
    {
    builder.addData(new PageElement(DATA, "\n", LEFT, font));
    }
    builder.addData(new PageElement(DATA, line2, LEFT, font));
    builder.addData(new PageElement(DATA, line3, LEFT, font));
    builder.addData(new PageElement(DATA, line4, LEFT, font));
    builder.addData(new PageElement(DATA, line5, LEFT, font));
    builder.getCurrentPage().setNoOfPagesToPrintPerJob (totalRows);
    book.append(builder.getCurrentPage(), job.defaultPage());

    }
    job.setPageable(book);


    try
    {
    if (job.printDialog())
    job.print();

    }
    catch (Exception ex)
    {
    JOptionPane.showMessageDialog(frame, ex.getMessage(), "Error Printing Envelopes", JOptionPane.ERROR_MESSAGE);
    ex.printStackTrace();
    }

    dialog.getProgressBar().setValue(dialog.getProgres sBar().getMaximum());
    dialog.closeWindow();
    frame.toFront();
    frame.addMessage("Label Printing completed...");
    }

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default

    Post your code between a pair of [CODE] tags.
    That is: [CODE]... your code goes here ... [/CODE]
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,767
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by PhHein View Post
    Post your code between a pair of [CODE] tags.
    That is: [CODE]... your code goes here ... [/CODE]
    And post your question only once, not in every subforum that crosses your way.

    kind regards,

    Jos

  4. #4
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default

    Quote Originally Posted by JosAH View Post
    And post your question only once, not in every subforum that crosses your way.

    kind regards,

    Jos
    Ayup, I've just reported abuse.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. Java Memory Issue
    By personal in forum Advanced Java
    Replies: 12
    Last Post: 01-07-2012, 03:05 PM
  2. focus issue in java 6
    By priyaa in forum AWT / Swing
    Replies: 2
    Last Post: 08-17-2010, 06:40 PM
  3. java 6 focus issue
    By priyaa in forum Advanced Java
    Replies: 2
    Last Post: 08-17-2010, 06:17 PM
  4. Java LinkedList Issue
    By Arunkumar in forum Advanced Java
    Replies: 6
    Last Post: 09-18-2009, 08:26 PM
  5. php issue (a little different from java I know!)
    By thomase in forum New To Java
    Replies: 5
    Last Post: 04-01-2009, 02:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •