We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › Java Application vs Applet - loss of formatting
Page Index Toggle Pages: 1
Java Application vs Applet - loss of formatting (Read 757 times)
Java Application vs Applet - loss of formatting
Aug 1st, 2008, 10:44am
 
Hi

I'm having a problem with line formatting.

I've got Processing running fine under Eclipse by extending PApplet (Test). I have a separate class with a main method that adds the first class to a JFrame (TestDriver).
My test app just draws a thick red line;
  stroke(155, 0, 0);
  strokeWeight(9);

If I run Test by itself as an Applet all is good until I resize the window (causing a redraw?). The instant I do that I lose all formatting and I'm left with a black line of weight 1.

Running TestDriver as an application displays the line fine, but without the formatting at all.
The only time I see formatting in the application is occasionally if I run the applet, then close and run the application. The thick red line will then be displayed - until I resize or rerun it.


I haven't been able to find anything about this - no idea if I'm using the right keywords though. What am I doing wrong? Am I supposed to be able to embed this in an application?

Cheers,
FrankyG
Re: Java Application vs Applet - loss of formattin
Reply #1 - Aug 9th, 2008, 4:50am
 
Duh. The answer just hit me today...

I set the stroke colour and weight in setup(), like all the examples show... if I move it to draw() everything works fine.

Obviously the stroke properties are being lost on a redraw - whether this is normal or not I have no idea.
Re: Java Application vs Applet - loss of formattin
Reply #2 - Aug 9th, 2008, 3:13pm
 
Yeah, a resize will nuke your settings for strokeWeight, textFont, etc. This is because the canvas has to be rebuilt. However, this isn't a good situation so I think we'll change it. It's also related to these two bugs:
http://dev.processing.org/bugs/show_bug.cgi?id=726
http://dev.processing.org/bugs/show_bug.cgi?id=767
Which happen even *without* the resize, which is definitely not the correct behavior. So I plan to fix all of these problems at the same time.
Page Index Toggle Pages: 1