I cannot get LibGDX logging to work in Android Studio. First i thought I had the same problem as my previous question but made sure my app updated on debug.
playButton.addListener(new ChangeListener()
{
#Override
public void changed(ChangeEvent event, Actor actor) {
Gdx.app.debug("BUTTON", "playButton Pressed");
optionButton.addAction(Actions.moveBy(-200, 0, 2));
}
});
The test action on the option button is carried out but i cannot get the debug log to show up.
The default Log level is LOG_INFO. For the Gdx.app.debug call to work, you must first call Gdx.app.setLogLevel(Application.LOG_DEBUG); once (probably the first line in your Game's constructor so you can easily change it).
Use Gdx.app.log or even System.out.println (write sout (syso in eclipse) and enter );
Related
I have encountered a problem when using the the addCommand() method of the Form class along with the Native theme - other themes work fine. See the following example:
Form hi = new Form("Hi World");
hi.addComponent(new Label("Hi World"));
// with native theme - can't click on the first command in the list
hi.addCommand(new Command("Dummy1") {
public void actionPerformed(ActionEvent ev) {
Dialog.show("Dummy1 Clicked!", "You clicked the Dummy1", "OK", null);
}
});
hi.addCommand(new Command("Dummy2") {
public void actionPerformed(ActionEvent ev) {
Dialog.show("Dummy2 Clicked!", "You clicked the Dummy2", "OK", null);
}
});
hi.show();
When I create an application using the code above, a click on the second command ("Dummy2") produces the expected Dialog, but a click on the first command ("Dummy1") does nothing.
This only happens when using the Native theme. If I switch to Flat Blue, then clicking on either command produces the expected Dialog.
This behavior happens both on the Simulator and on a real Android device (don't know about iOS).
Fyi, my toolchain is NetBeans IDE v8.2, Java 1.8.0_25, with the CodenameOne plugin v3.6.0.
Has anyone else seen this? Am I missing something? If so, is there a workaround?
If the element is very narrow and very close to the top the click might be misinterpreted as a click out of bounds or on the status bar area. You need to set the styling of the SideCommand to have a sensible default as this element is very application specific. Otherwise touches might be lost.
I tried styling the SideCommand but it didn't seem to help. What worked for me was to define a style for TitleArea and simply uncheck Derived for the Padding settings (I left them all set to 0px).
I have no idea why this works - I would have thought that the derived values would have been zero in any case.
I am making a JavaFX kiosk application that needs to take full control of the screen and disallow closing, minimising, and certain keypresses. I was wondering is there a way to make a JavaFX application run in full screen exclusive mode, if not are there any alternatives that could achieve the same goal. I have tried using:
stage.setFullScreen(true);
which does successfully make the application full screen, however the user can still exit the application or exit the full screen.
Handle close events.
following code may help!
// Set plat params
Platform.setImplicitExit(false);
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
#Override
public void handle(WindowEvent event) {
// deque it
event.consume();
}
});
I had this same issue recently, hopefully you figured it out (I wouldn't wait 4 years for an answer).
If not:
Before you make a call to stage.show() you need to call setFullScreenExitKeyCombination and pass KeyCombination.NO_MATCH as the only parameter.
so for example...
stage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);
stage.show()
This will prevent closing and de-fullscreening w/ESC (but still leave you with a backdoor-y way to remove fullscreen - Shift+PAUSE or F13):
scene.setOnKeyPressed((event) ->
{
if (event.getCode() == KeyCode.PAUSE && event.isShiftDown())
stage.setFullScreen(!stage.isFullScreen());
});
stage.setOnCloseRequest(Event::consume);
stage.setFullScreenExitKeyCombination(new KeyCodeCombination(KeyCode.F13));
In order to close your application you'd have to add a Platform.exit() on some command.
So in menu i have 3 buttons and all are with the same code. For the topic only important thing is
button2.addListener(new InputListener() {
#Override
public boolean touchDown(InputEvent event, float x, float y,
int pointer, int button) {
game.setGame();
dispose();
return true;
}
});
Then everything is going fine until:
button3.clearListeners(); // MainMenu.java:174 line in exeption
and then exeption pops out:
Exception in thread "LWJGL Application" java.lang.IllegalStateException: Invalid between begin/end.
at com.badlogic.gdx.utils.DelayedRemovalArray.clear(DelayedRemovalArray.java:125)
at com.badlogic.gdx.scenes.scene2d.Actor.clearListeners(Actor.java:261)
at com.racostyle.avdelux.MainMenu.dispose(MainMenu.java:174)
at com.racostyle.avdelux.MainMenu$3.touchDown(MainMenu.java:123)
at com.badlogic.gdx.scenes.scene2d.InputListener.handle(InputListener.java:55)
at com.badlogic.gdx.scenes.scene2d.Actor.notify(Actor.java:165)
at com.badlogic.gdx.scenes.scene2d.Actor.fire(Actor.java:136)
at com.badlogic.gdx.scenes.scene2d.Stage.touchDown(Stage.java:277)
at com.badlogic.gdx.backends.lwjgl.LwjglInput.processEvents(LwjglInput.java:300)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:200)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
EDIT: if i don't remove listeners they are still active and can be clickable, afc with exeptions.
It looks like you're calling MainMenu.dispose within an actor.touchdown listener. MainMenu.dispose clears all listeners on a button. LIBGX won't allow that.
Why? Because LIBGDX is in the process of calling touch events on a lot of actors. You really don't want your game functioning different depending on the order buttons were added to your stage.
So, call clear listeners somewhere else.
Since you're doing this within a dispose method anyway, I'd suggest NOT removing your button listeners at all, as the actor you've registered listeners for should not be used again.
Its not allowed to just call clearListeners() without event;
Will you post your codes in jsfiddle.. i will try to debug it and add some codes..
Thanks ..
I am developing the network application in which I want to run my J2ME MIDP application in background without any GUI so that is any way to construct the application is such manner.
try this
set your current Display to null. so there will not be any form or alert running on the screen. But however your code will be running in the background.
Display display = Display.getDisplay(this); // here 'this' points to Midlet
display.setCurrent(null);
it easy just have a code of line on any event for example in the click of button
Display.getDisplay (this).setCurrent (null);
and return back the control via
Display.getDisplay (this).setCurrent (mycanvas);
Yes this code works Good,
display = Display.getDisplay(this);
public void startApp()
{
display.setCurrent(form);
}
public void pauseApp()
{
}
public void hide()
{
Display.getDisplay (this).setCurrent (null);
}
This is will work like, make a button can after clicking it call hide Function, or you call this hide function in constructor so it will hide itself when app start, can you keep unHide statement in appStart() so if you Tab the program then it will unHide app again.
NOTE: you said you are working on Network app, but some mobile will turn off the Internet Connection, when the Mobile screen Turn Off. please check this. and If you found any solution It will be Good to share here.
I have a Java/Swing desktop application (Java 6u16 on Windows XP) which occasionally appears to the users to hang. I say appears to because in reality what is happening is that the application is showing a modal dialog but this dialog is not being rendered. If the user uses Alt-Tab to switch away from the application and then subsequently returns to it, the dialog gets rendered correctly. Additionally, if a remote user connects to the session via NetOp (a VNC/Remote Desktop workalike) this also causes the GUI to be redrawn correctly.
The app runs via JavaWebstart. Since I've heard of rendering issues being caused by DirectDraw, I added the following to the JNLP
<property name="sun.java2d.noddraw" value="true"/>
but the problem still occurs (If I have understood correctly, this will switch off DirectDraw and Direct3d completely: see http://download.oracle.com/javase/1.5.0/docs/guide/2d/flags.html#noddraw)
I'm out of ideas on this one, any suggestions would be greatly appreciated.
Thanks,
Phil
Edit...
I have an abstract dialog class which extends JDialog and which all other dialogs extend. It contains the following method:
public void showDialog() {
initKeyBindings();
Application.getApplication().deactivateScannerListener();
setVisible(true);
}
Whenever I want to display a dialog, I call showDialog(). The initKeyBindings method sets up an ActionMap while the second line is application specific (Application is a singleton, I'm disabling the JPOS scanner listener while the dialog is displaying).
There is a corresponding hideDialog() method as follows:
public void hideDialog() {
setVisible(false);
Application.getApplication().activateScannerListener();
dispose();
}
Thanks,
Phil
Edit...
Sorry about this, one more edit: all of the dialogs have a parent. The AbstractDialog class will default to the main application frame if no other parent is specified.
FYI
For anyone following this, I've added the following to my code:
if (SwingUtilities.isEventDispatchThread()) {
initialiseAndShowDialog();
} else {
SwingUtilities.invokeAndWait(new Runnable() {
#Override
public void run() {
initialiseAndShowDialog();
}
});
}
This ensures that the dialog is only opened from the EDT.
Which thread are you calling showDialog() from? Swing components should be accessed on the Event Dispatch Thread only.
You could try SwingUtilities.invokeAndWait()
and the Runnable argument passed to it should call showDialog().
Let us know if it fixed the problem.