Revision: 2381
http://sourceforge.net/p/swingme/code/2381
Author: yuranet
Date: 2019-12-06 20:21:20 +0000 (Fri, 06 Dec 2019)
Log Message:
-----------
fix random window opening
Modified Paths:
--------------
me4se/build.xml
me4se/opt/swingme/src/net/yura/me4se/ME4SEPanel.java
me4se/src/javax/microedition/lcdui/Image.java
me4se/src/javax/microedition/midlet/ApplicationManager.java
Modified: me4se/build.xml
===================================================================
--- me4se/build.xml 2019-09-26 23:56:53 UTC (rev 2380)
+++ me4se/build.xml 2019-12-06 20:21:20 UTC (rev 2381)
@@ -89,7 +89,7 @@
</patternset>
</unzip>
- <javac srcdir="src;opt/pim/src;opt/m3g/src;opt/contactless/src;opt/location/src;opt/bluetooth/src;opt/bluetooth/src_gcfimpl_avetanabt;opt/swingme/src" source="1.4" classpath="lib/emptycommapi.jar;opt/m3g/lib/jogl.jar;opt/contactless/lib/Phidget21.jar;opt/bluetooth/lib/avetanaBluetooth.jar;lib/Grasshopper.jar;opt/swingme/lib/SwingME.jar" destdir="tmpclasses" debug="on" target="1.4">
+ <javac srcdir="src;opt/pim/src;opt/m3g/src;opt/contactless/src;opt/location/src;opt/bluetooth/src;opt/bluetooth/src_gcfimpl_avetanabt;opt/swingme/src" source="1.4" classpath="lib/emptycommapi.jar;opt/m3g/lib/jogl.jar;opt/contactless/lib/Phidget21.jar;opt/bluetooth/lib/avetanaBluetooth.jar;lib/Grasshopper.jar;opt/swingme/lib/SwingME.jar" destdir="tmpclasses" debug="on" target="1.4" encoding="Cp1252">
</javac>
Modified: me4se/opt/swingme/src/net/yura/me4se/ME4SEPanel.java
===================================================================
--- me4se/opt/swingme/src/net/yura/me4se/ME4SEPanel.java 2019-09-26 23:56:53 UTC (rev 2380)
+++ me4se/opt/swingme/src/net/yura/me4se/ME4SEPanel.java 2019-12-06 20:21:20 UTC (rev 2381)
@@ -21,9 +21,9 @@
*/
public class ME4SEPanel extends Container {
- private ApplicationManager manager;
- private DesktopPane desktop,old;
- private Frame frame1;
+ private ApplicationManager manager, oldManager;
+ private DesktopPane desktop, oldDesktop;
+ private Frame swingMEFrame;
public DesktopPane getDesktopPane() {
return desktop;
@@ -34,7 +34,8 @@
// this can only be happening in 1 thread at a time
- old = DesktopPane.getDesktopPane();
+ oldManager = ApplicationManager.isInitialized() ? ApplicationManager.getInstance() : null;
+ oldDesktop = DesktopPane.getDesktopPane();
manager = ApplicationManager.createInstance(this, null );
@@ -65,21 +66,24 @@
Field man = ApplicationManager.class.getDeclaredField("manager");
man.setAccessible(true);
if (man.get(null) == manager) {
- System.out.println("[ME4SEPanel] setting manager to null");
- man.set(null, null);
+ // we want to set it back to the old 1 or it will end up trying to
+ // create a new manager, and a new frame, then it may set that frame to visible
+ // e.g. make me4sePanel1, make me4sePanel2, close me4sePanel2, goto me4sePanel1, click into textbox
+ System.out.println("[ME4SEPanel] setting manager to old manager " + oldManager);
+ man.set(null, oldManager);
+ oldManager = null;
}
((EmptyMidlet)manager.active).destroyApp(true); // this will set desktop to null
- if (old!=null) {
- old.showNotify();
- old=null;
+ if (oldDesktop != null) {
+ oldDesktop.showNotify();
+ oldDesktop = null;
}
}
catch(Exception ex) {
throw new RuntimeException(ex);
}
-
}
public java.awt.Component getComponent() {
@@ -88,11 +92,11 @@
public void add(Component panel) {
- if (frame1!=null) {
- desktop.remove(frame1);
+ if (swingMEFrame!=null) {
+ desktop.remove(swingMEFrame);
}
-
- frame1 = new Frame() {
+
+ swingMEFrame = new Frame() {
// do not allow anyone to close this window
// if anyone tries, close the Swing Window instead
public void setVisible(boolean b) {
@@ -104,12 +108,12 @@
}
}
};
- frame1.setUndecorated(true);
- frame1.getContentPane().add(panel);
- frame1.setMaximum(true);
+ swingMEFrame.setUndecorated(true);
+ swingMEFrame.getContentPane().add(panel);
+ swingMEFrame.setMaximum(true);
//frame1.addWindowListener(this); // this is not good enough as does not catch someone
// calling "frame1.setVisible(false);" directly
- desktop.add(frame1);
+ desktop.add(swingMEFrame);
}
public void showDialog(java.awt.Frame parent, String title) {
@@ -138,18 +142,17 @@
// TODO can only show once per instance of a ME4SEPanel ?!
destroy();
-
}
public Dimension getMinimumSize() {
Dimension d = super.getPreferredSize();
- if (frame1!=null) {
- Dimension a = new Dimension( frame1.getWidth(), frame1.getHeight());
- frame1.pack(); // TODO: does this really set the height right away to the min???
- Dimension b = new Dimension( frame1.getWidth(), frame1.getHeight());
+ if (swingMEFrame!=null) {
+ Dimension a = new Dimension( swingMEFrame.getWidth(), swingMEFrame.getHeight());
+ swingMEFrame.pack(); // TODO: does this really set the height right away to the min???
+ Dimension b = new Dimension( swingMEFrame.getWidth(), swingMEFrame.getHeight());
//System.out.println("d="+d);
- frame1.setSize(a.width, a.height);
+ swingMEFrame.setSize(a.width, a.height);
return b;
}
Modified: me4se/src/javax/microedition/lcdui/Image.java
===================================================================
--- me4se/src/javax/microedition/lcdui/Image.java 2019-09-26 23:56:53 UTC (rev 2380)
+++ me4se/src/javax/microedition/lcdui/Image.java 2019-12-06 20:21:20 UTC (rev 2381)
@@ -84,6 +84,9 @@
* @ME4SE INTERNAL
*/
protected Image(BufferedImage image, boolean mutable, boolean toGray, String name) {
+ if (image == null) {
+ throw new NullPointerException("img can not be null");
+ }
//Display.check();
// Give VM some time to cleanup every n images...
Modified: me4se/src/javax/microedition/midlet/ApplicationManager.java
===================================================================
--- me4se/src/javax/microedition/midlet/ApplicationManager.java 2019-09-26 23:56:53 UTC (rev 2380)
+++ me4se/src/javax/microedition/midlet/ApplicationManager.java 2019-12-06 20:21:20 UTC (rev 2381)
@@ -1319,6 +1319,10 @@
return menuBar;
}
+ public String toString() {
+ return "ApplicationManager {awtContainer=" + awtContainer + "}";
+ }
+
/**
* tell us what assets to load and display:
* 1 is mdpi normal,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|