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

    Default focus issue in java 6

    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
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,332
    Rep Power
    25

    Default

    Can you make a small program that compiles, executes and demonstrates the problem?
    Please put the code in code tags when you post it.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    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, 02:05 PM
  2. Java - Linux Issue
    By mhyndavi in forum Advanced Java
    Replies: 4
    Last Post: 06-15-2010, 06:40 AM
  3. Java LinkedList Issue
    By Arunkumar in forum Advanced Java
    Replies: 6
    Last Post: 09-18-2009, 07:26 PM
  4. php issue (a little different from java I know!)
    By thomase in forum New To Java
    Replies: 5
    Last Post: 04-01-2009, 01:02 AM
  5. Java Applet Issue
    By bmw4l1f3 in forum New To Java
    Replies: 9
    Last Post: 11-13-2008, 04:39 PM

Posting Permissions

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