Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > IE won't show applet in print preview

Reply
Thread Tools

IE won't show applet in print preview

 
 
KenH
Guest
Posts: n/a
 
      08-17-2005
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.

 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      08-17-2005
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'
 
Reply With Quote
 
 
 
 
KenH
Guest
Posts: n/a
 
      08-17-2005
Yes. It is very frustrating. I'm just banging my head trying to create
an idiot-proof printing process for this applet.

 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      08-17-2005
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'
 
Reply With Quote
 
KenH
Guest
Posts: n/a
 
      08-18-2005
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">

 
Reply With Quote
 
Thomas Hawtin
Guest
Posts: n/a
 
      08-18-2005
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/
 
Reply With Quote
 
KenH
Guest
Posts: n/a
 
      08-18-2005
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Firefox 2 print and print preview only shows first page R.Ig Firefox 3 02-14-2007 01:10 AM
Images missing in IE 6 print and print preview seth7f@gmail.com HTML 0 01-16-2007 03:30 PM
internet explorer print preview VERSUS print eunever32@yahoo.co.uk HTML 2 11-22-2006 02:03 PM
Preview: Dystopia Preview Silverstrand Front Page News 0 02-05-2006 03:15 AM
display print preview dialog, not print dialog Matt Javascript 1 11-20-2004 01:18 AM



Advertisments