How Create Message Windows in a App

Hello,

i’m doing an app in OS Android. I need to generate one window or popup message when a touch an object in the game. I don’t know how to generate this popup. I have implemented this jFrame but when i generate the APK and execute in my mobile device generate this error:

JFrame Implemented:
public void helpAndroid(){
if (OsDetector.getInstance().isAndroid()){
if(frameAyudaAnd == null){
frameAyudaAnd = new JFrame(“Ayuda Android”);
frameAyudaAnd.pack();
frameAyudaAnd.setLocationRelativeTo(null);
frameAyudaAnd.setResizable(false);
frameAyudaAnd.setVisible(true);
}
}
}

Error Generate when is execute the apk in the mobile:
java.lang.NoClassDefFoundError:
javax.swing.JFrame
Exception thrown in Thread[GLThread 1378,5,main]
java.lang.NoClassDefFoundError:
javax.swing.JFrame at mygame.Main.helpAndroid(Main.java:468)

You can’t really use Desktop GUI stuff on Android. Use the native android API:

http://developer.android.com/guide/topics/ui/dialogs.html

But, i need add the library to design the popup window in JME?. Because i want to implemented this Class in JME to generate the popup:

public class FireMissilesDialogFragment extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the Builder class for convenient dialog construction
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(R.string.dialog_fire_missiles)
.setPositiveButton(R.string.fire, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// FIRE ZE MISSILES!
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User cancelled the dialog
}
});
// Create the AlertDialog object and return it
return builder.create();
}
}

For future reference:

Oh, sorry, i’m new. How can i implemented this code in JMonkey?
[java]public class FireMissilesDialogFragment extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the Builder class for convenient dialog construction
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(R.string.dialog_fire_missiles)
.setPositiveButton(R.string.fire, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// FIRE ZE MISSILES!
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User cancelled the dialog
}
});
// Create the AlertDialog object and return it
return builder.create();
}
}[/java]

Connect it through the MainActivity:

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:android

If you don’t actually need the native gui, then doing it in jME code would make it cross platform, or using a GUI Framework: Nifty/Lemur/t0neg0d

Hello,

I need to create a popup window in my app for android, and i’m using Nifty but the problem now is the execution time the popup window. How can i create a popup window for android? or how can i do to decrease the execution time using Nyfty?.

Thanks.

@CristianGaitanG said: Hello,

I need to create a popup window in my app for android, and i’m using Nifty but the problem now is the execution time the popup window. How can i create a popup window for android? or how can i do to decrease the execution time using Nyfty?.

Thanks.

If you are simply trying to display a message (as in alert or dialog), I’d go the route @wezrule mentioned as a secondary option. If Nifty is not performing as you’d like, look at Lemur or tonegodGUI.

Using a native Popup in android is going to be problematic right now until someone figures out a way of having the JME display play nice with other layout components. I’m working on this currently, but just started looking at a way of solving this (this is needed for Play Games Services and Facebook integration… and I’ve had little success so far… though, the good news is I’ve only spent about an hour so far… so there is hope!).

I have worked with lemur and it worked perfectly on android, Thanks.
But now i have to put it an image, can i do it with lemur?

Thanks again.

@CristianGaitanG said: I have worked with lemur and it worked perfectly on android, Thanks. But now i have to put it an image, can i do it with lemur?

Thanks again.

Yes, there are a few different ways. What do you have so far and what is the effect you are trying to achieve? If it’s not too much trouble, maybe you can make a post in the Lemur section of the forum with a little more detail. I’d be glad to help.

http://hub.jmonkeyengine.org/forum/board/projects/lemur/

ok thanks, would be helpful.
Already I made the post in the link.
http://hub.jmonkeyengine.org/forum/topic/how-add-images-in-a-panel-using-lemur/

1 Like

can i hide a window created in Lemur?. I want to show this windows when touch a special object, and later i want to hide or close this window when i touch another object. can i hide or close the window?
thanks for youb help.

@CristianGaitanG said: can i hide a window created in Lemur?. I want to show this windows when touch a special object, and later i want to hide or close this window when i touch another object. can i hide or close the window? thanks for youb help.

Yes, I answered in the other thread, though.