IE won't show applet in print preview

Discussion in 'Java' started by KenH, Aug 17, 2005.

  1. KenH

    KenH Guest

    Is there something about Swing that Internet Explorer doesn't like?
    Before I started using it in my applet I could print the page through
    IE, but now the applet just shows up as blank in the preview and if you
    print.
     
    KenH, Aug 17, 2005
    #1
    1. Advertising

  2. On 17 Aug 2005 08:43:23 -0700, KenH wrote:

    > Is there something about Swing that Internet Explorer doesn't like?


    This seems like a close rerun of another thread you started
    <http://groups.google.com.au/group/comp.lang.java.programmer/browse_frm/thread/64dcd8a3bbfc4b44/4f0d31452f0a760d#4f0d31452f0a760d>

    You will probably find it gets much the same answers.

    The only thing I would add is. Check your console.
    I will also reiterate.. (from the other thread)
    >> [ Read the entire FAQ - lots on applets. ]


    --
    Andrew Thompson
    physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
    "I've lost my shirt, I've pawned my rings. I've done all the dumb things."
    Paul Kelly 'Dumb Things'
     
    Andrew Thompson, Aug 17, 2005
    #2
    1. Advertising

  3. KenH

    KenH Guest

    Yes. It is very frustrating. I'm just banging my head trying to create
    an idiot-proof printing process for this applet.
     
    KenH, Aug 17, 2005
    #3
  4. On 17 Aug 2005 09:57:27 -0700, KenH wrote:

    > Yes. It is very frustrating. ..


    It is very frustrating you dropping out of conversations
    that are not going the way you like.

    Do you expect me to re-ask the questions I asked before,
    or are you hoping they will just go way? Do you think
    the answers may have changed in the last ..22 hours?

    You still have not provided an URL or example code.

    What do you expect us to do to resolve your problem,
    guess randomly?

    --
    Andrew Thompson
    physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
    "Don't just take me for tryin' to be heavy. Understand, it's time to get
    ready.."
    Stevie Ray Vaughan and Double Trouble 'Couldn't Stand The Weather'
     
    Andrew Thompson, Aug 17, 2005
    #4
  5. KenH

    KenH Guest

    I need to print in different applets so I wrote a separate class. I
    call that class in the routine that hanldles button and keyboard
    events. This is the code that captures the applet print button being
    pressed. It works perfectly:

    // figure out what kind of action happened (keyboard button pressed,
    button clicked)
    public void actionPerformed(ActionEvent ae) {
    String str = ae.getActionCommand();
    double n, m;
    displayPrint p = new displayPrint();
    String tl;
    ...
    other events are handled
    ...

    // process Print button if pressed
    if (str.equals("Print")) {
    // turn off double buffering to get a high-res print
    dbuffering = false;

    p.FORMAT = "LANDSCAPE";
    p.printComponent(this);

    // turn on double buffering
    dbuffering = true;
    }
    repaint();
    }

    ------------------------------------------------------------------------------------------------
    This is the code that I call from a javascript function. It does NOT
    work:

    // print method activated by external code, usually a javascript
    function
    public void remotePrint() {
    displayPrint p = new displayPrint();

    // turn off double buffering to get a high-res print
    dbuffering = false;

    p.FORMAT = "LANDSCAPE";
    p.printComponent(this);

    // turn on double buffering
    dbuffering = true;

    repaint();
    }

    I'm not 'swallowing' exceptions...the console shows nothing and I don't
    catch exceptions and do nothing with them. The Java dialog box actually
    comes up warning me that the applet is trying to print something (which
    is what is does when I print from the button on the applet.)

    Below is the code for the button in the HTML. It calls the method that
    does not work:

    <input class="flatbutton" onclick="document.applets(0).remotePrint();"
    type="button" value="Print" name="cpy">
     
    KenH, Aug 18, 2005
    #5
  6. KenH wrote:
    >
    > This is the code that I call from a javascript function. It does NOT
    > work:
    >
    > // print method activated by external code, usually a javascript
    > function
    > public void remotePrint() {


    I've not done any Java/JavaScript mixing. It might be useful to check
    that you are in the AWT Event Dispatch Thread, using
    EventQueue.isDispatchThread(). Perhaps use
    EventQueue.invokeLater/javax.swing.Timer to make things as absolutely
    similar as possible.

    Tom Hawtin
    --
    Unemployed English Java programmer
    http://jroller.com/page/tackline/
     
    Thomas Hawtin, Aug 18, 2005
    #6
  7. KenH

    KenH Guest

    I think you hit on somethig.

    I did a like more digging and found another news thread that alluded to
    a some kind of thread issue. Not completely sure why this works but the
    method:

    // fake a button push to start the print job
    public void remotePrint () {
    Runnable doClick = new Runnable() {
    public void run () {
    print_bt.doClick();
    }
    };
    // pretend user clicked your own button.
    SwingUtilities.invokeLater(doClick);
    }

    worked! Basically I'm faking pushing the Print button on the applet,
    which runs the method that DOES work.
     
    KenH, Aug 18, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    477
  2. Replies:
    0
    Views:
    1,000
  3. rote
    Replies:
    0
    Views:
    440
  4. Matt
    Replies:
    1
    Views:
    279
    Randy Webb
    Nov 20, 2004
  5. Replies:
    1
    Views:
    124
    Randy Webb
    Apr 7, 2006
Loading...

Share This Page