Hello everyone! I am newbie on Pivot. I'm trying to migrate a complex web application to Java. Pivot in my best choice due to its strong relation to Java and I'm currently reaching all the functionality :).
Due to complexity issues, related to some different applications I am going to need different applets interacting. I had already reached that goal. And right now for testing some particular concept I only have the following two: 1. A Pivot application. Currently a simple one with only one single button (then it will be substituted by my real app) 2. a Loader from LWJGL (http://www.lwjgl.org/applet/) I'm using this and not some loader in pivot because it already meets all my needs. This loader is indeed an applet that will load a second applet (in my case that one generating my pivot application) and it does it when it was done with jar downloading. The thing is that all this is working but with one simple failure: when the loader (2) had done and switch to the applet (1) (which will indeed load the pivot application) it actually load it but it is not painting it, I know this be cause if I force repainting (resizing the browser window reaching the zone where the applet is) then the pivot application shows up normally. And before resizing I got all the debug messages (in my java console) that I am printing to know if the startup method is being called entirely and it is!. So the only problem is the first painting. I have looked into the Pivot's API and also googled to to find something that will help me to force painting at the end of the startup method but I had only found paint and repaint methods and used it with no results. Can anyone tell me if I am doing something wrong? I also look for something relative to this inside this mailing list and some issues on repainting and the only similar was fixed with "Be sure to wrap your TaskListener in a TaskAdapter. TaskListeners are called on the background thread. TaskAdapters ensure that they are called on the UI thread." The thing is that I am not taking care of any TaskListener, should I? may be a simple example will be useful for me. CODE: my loader (1) has init, start, run, stop and destroy methods (among others) those important are: ______________________________________ AppletLoader : ______________________________________ public void start() { if (secondApplet != null) { secondApplet.start(); } else { if(loaderThread == null && !fatalError) { loaderThread = new Thread(this); loaderThread.setName("AppletLoader.loaderThread"); loaderThread.start(); animationThread = new Thread() { public void run() { while(loaderThread != null) { repaint(); AppletLoader.this.sleep(100); } repaint(); animationThread = null; } }; animationThread.setName("AppletLoader.animationthread"); animationThread.start(); } } } public void run() { state = STATE_CHECKING_CACHE; ... try { . .... // if jars not available or need updating download them if (!cacheAvailable) { // downloads jars from the server downloadJars(path); // 10-55% // Extract Pack and LZMA files extractJars(path); // 55-65% // Extracts Native Files //extractNatives(path); // 65-85% // add version information once jars downloaded successfully if (version != null) { percentage = 90; writeVersionFile(dir, latestVersion); } } // add the downloaded jars and natives to classpath updateClassPath(path); // switch to secondApplet switchApplet(); state = STATE_DONE; } catch (AccessControlException ace) { ....... } } protected void switchApplet() throws Exception { state = STATE_SWITCHING_APPLET; percentage = 100; debug_sleep(2000); Class appletClass = classLoader.loadClass(getParameter("al_main")); secondApplet = (Applet) appletClass.newInstance(); secondApplet.setStub(this); secondApplet.setSize(getWidth(), getHeight()); setLayout(new BorderLayout()); add(secondApplet); validate(); state = STATE_INITIALIZE_REAL_APPLET; secondApplet.init(); state = STATE_START_REAL_APPLET; secondApplet.start(); } ______________________________________ Pivot application: ______________________________________ @Override public void startup(Display disp, Map<String, String> properties) { label = new Label(); label.setText("Welcome to the simple application!"); label.getStyles().put("font", new Font("Arial", Font.BOLD, 20)); label.getStyles().put("color", Color.DARK_GRAY); label.getStyles().put("horizontalAlignment", HorizontalAlignment.CENTER); label.getStyles().put("verticalAlignment", VerticalAlignment.CENTER); pushButton = new PushButton("Call to the BIG application!"); pushButton.getButtonPressListeners().add(new ButtonPressListener() { @Override public void buttonPressed(Button button) { System.out.println("button pressed"); org.apache.pivot.wtk.BrowserApplicationContext.eval("callingJavaScript();", main.this); } }); boxPane = new BoxPane(); boxPane.add(pushButton); boxPane.add(label); //setting box style: boxPane.getStyles().put("padding", 20); boxPane.getStyles().put("horizontalAlignment", "center"); boxPane.getStyles().put("verticalAlignment", "center"); boxPane.getStyles().put("backgroundColor", Color.GRAY); window = new Window(); window.setContent(boxPane); window.getStyles().put("backgroundColor", Color.GRAY); window.setTitle("Hello World!"); window.setMaximized(true); window.open(disp); //MY CODE ENDED IN THE PREVIOUS LINE and the followings are all the attempts to repaint: // window.paint(window.getGraphics()); // boxPane.paint(window.getGraphics()); // boxPane.paint(boxPane.getGraphics()); // window.paint(window.getGraphics()); // window.requestFocus(); // window.repaint(); // disp.repaint(); // disp.requestFocus(); // disp.paint(disp.getGraphics()); // window.paint(disp.getGraphics()); } IMPORTANT: I am not using WTKX, only java to define all objects for this case I rather in this way. Obviously this pivot application when running alone is working so do the Loader (loading a simple applet, not pivot, it works) Is there something related with the UI thread? Am I doing something wrong? Is a mistake omitting WTKX definition? Is there a way for me to know what is the method that is called when I resize and the second applet is repainted ONLY when the browser's window border reaches the zone when the second applet supposed to be. Probably my computer? I'm running on an IMac (Intel-based) Mac OS X (10.6.3) and this thing happens in Firefox 3.6.6 and the same with Safari 4.0.5 both with the java console running (enabled) since applet start It will be pretty helpful to me to know what is happening here, what is the difference in my repaint and that done when resizing. Thanks in advance! I I really want to use Pivot in my project and if this is not possible, may me I am going to need to develop some loader in pivot with the same functionality but may be loading the other applets I will get the same problem. Thanks all of you, any piece of advise will be helpful!
