I have a problem while creating selectbox on libgdx.
Skin.add("button", new Texture("data/menu/button.png"));
[...]
SelectBoxStyle selectboxstyle = new SelectBoxStyle();
selectboxstyle.font = new BitmapFont(Gdx.files.internal("data/fonts/menufont.fnt"), Gdx.files.internal("data/fonts/menufont.png"), false);`
selectboxstyle.background = Skin.getDrawable("button");
SelectBox dropdown = new SelectBox(new String[] {"item1", "item2"}, selectboxstyle);
The last line throw exception:
Exception in thread "LWJGL Application" java.lang.NullPointerException
at
com.badlogic.gdx.scenes.scene2d.ui.SelectBox.setItems(SelectBox.java:140)
at
com.badlogic.gdx.scenes.scene2d.ui.SelectBox.(SelectBox.java:71)
at com.me.Terminum.Screens.MainMenu.ShowVideo(MainMenu.java:171) at
com.me.Terminum.Screens.MainMenu.show(MainMenu.java:121) at
com.badlogic.gdx.Game.setScreen(Game.java:62) at
com.me.Terminum.Screens.SplashScreen.show(SplashScreen.java:88) at
com.badlogic.gdx.Game.setScreen(Game.java:62) at
com.me.Terminum.App.create(App.java:13) at
com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:136)
at
com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
I checked it on libgdx 0.9.8 and 0.9.9. What am I do wrong?
I found the answer.
Everything that is not marked as optional must be populated. And additionaly, ScrollPaneStyle.background must be filled (even is it marked as optional). Without this, libgdx threw me an exception.
Related
My model is done using "FilteredClassifier" algorithm, then SMO as a
"classifier" parameter. "weka.classifiers.functions.SMO".
I tried to load my model into java using this code but it is not work
SupportVector SOM = (SupportVector) SerializationHelper.read(new
FileInputStream("C:\\Users\\HP\\Desktop\\SOM.model"));
and this code
FilteredClassifier SOM = (FilteredClassifier )
SerializationHelper.read(new
FileInputStream("C:\\Users\\HP\\Desktop\\SOM.model"));
both not working
then I want to browse the data used in building this model (actual value and predicted value).
how I can do it? Once I have created the model, do I need to load the dataset again?
This is the error
Exception in thread "main" java.lang.ClassCastException: weka.classifiers.meta.FilteredClassifier cannot be cast to weka.core.pmml.jaxbbindings.SupportVector
at weka.api.Model.main(Model.java:28)
This is the error
Exception in thread "main" java.lang.ClassCastException: weka.classifiers.meta.FilteredClassifier cannot be cast to weka.core.pmml.jaxbbindings.SupportVector
at weka.api.Model.main(Model.java:28)
weka.classifiers.meta.FilteredClassifier cannot be cast to weka.core.pmml.jaxbbindings.SupportVector
pmml and jaxb are XML related classes, you appear to have imported the wrong package.
So I have recently started learning libgdx in Android Studio. I am using some extensions like box2d. To create some nice borders around the object, I am using Physics Body Editor. So, as there were many errors in my own code, i have just copied one from here: Code Sample. But still, I keep getting an error on the following line:
BodyEditorLoader loader = new BodyEditorLoader(Gdx.files.internal("tankA.json"));
The file tankA.json is in my assets folder.
Here is my error:
02-12 08:27:52.216 13720-13734/com.tynibattles04.game.android E/AndroidRuntime﹕ FATAL EXCEPTION: GLThread 6581
Process: com.tynibattles04.game.android, PID: 13720
com.badlogic.gdx.utils.GdxRuntimeException: Error reading file: tankA.json (Internal)
at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:77)
at com.badlogic.gdx.files.FileHandle.length(FileHandle.java:605)
at com.badlogic.gdx.backends.android.AndroidFileHandle.length(AndroidFileHandle.java:220)
at com.badlogic.gdx.files.FileHandle.estimateLength(FileHandle.java:233)
at com.badlogic.gdx.files.FileHandle.readString(FileHandle.java:198)
at com.badlogic.gdx.files.FileHandle.readString(FileHandle.java:191)
at aurelienribon.bodyeditor.BodyEditorLoader.<init>(BodyEditorLoader.java:41)
at com.tynibattles04.game.TinyBattles.createBottle(TinyBattles.java:127)
at com.tynibattles04.game.TinyBattles.create(TinyBattles.java:74)
at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:241)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1512)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
Caused by: java.io.FileNotFoundException: tnkA.json
at android.content.res.AssetManager.openAsset(Native Method)
at android.content.res.AssetManager.open(AssetManager.java:355)
at android.content.res.AssetManager.open(AssetManager.java:329)
at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:75)
Do you know what could i do with all that?
Thanks in advance!
I have accidentally misspelled tankA.json in the error code - thanks to Angel Angel. But I still keep getting the same error. Maybe that's be cause something wrong this the BodyEditorLoader?
Check the file name and the name you use to load, then you say:
BodyEditorLoader loader = new BodyEditorLoader(
Gdx.files.internal("tankA.json"));
But in stack says:
com.badlogic.gdx.utils.GdxRuntimeException:
Error reading file:
tnkA.json (Internal)
maybe this is an error in the file name: tnkA.json
note: maybe in your code use, tnkA.json and not tankA.json as you think.
hope it helps.
I clearly stored my "background.png" in the assets folder under android.
I also checked that it was there in Finder.
I am working with Android Studio.
However, upon trying to access the image:
public Background() {
textureRegion = new TextureRegion(new Texture("background.png"));
textureRegionBounds1 = new Rectangle(0 - Constants.APP_WIDTH / 2, 0, Constants.APP_WIDTH, Constants.APP_HEIGHT);
textureRegionBounds2 = new Rectangle(Constants.APP_WIDTH / 2, 0, Constants.APP_WIDTH, Constants.APP_HEIGHT);
}
I get this error:
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: background.png
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140)
at com.badlogic.gdx.graphics.TextureData$Factory.loadFromFile(TextureData.java:98)
at com.badlogic.gdx.graphics.GLTexture.createTextureData(GLTexture.java:185)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:103)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:95)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:91)
at com.com.waylonhuang.game.actors.Background.<init>(Background.java:21)
at com.com.waylonhuang.game.stages.GameStage.setUpBackground(GameStage.java:66)
at com.com.waylonhuang.game.stages.GameStage.setUpWorld(GameStage.java:59)
at com.com.waylonhuang.game.stages.GameStage.<init>(GameStage.java:51)
at com.mygdx.game.GameScreen.<init>(GameScreen.java:16)
at com.mygdx.game.DrifterGame.create(DrifterGame.java:11)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:137)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: background.png (Internal)
at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136)
at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:222)
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
... 13 more......
What am I missing?
EDIT
Also, my current path for the Desktop launcher for the Working Directory is : AndroidStudioProjects/libGDXGame
However, upon changing it to: AndroidStudioProjects/libGDXGame/android/assets
I get a new error like such:
Exception in thread "LWJGL Application" java.lang.NullPointerException
at com.com.waylonhuang.game.stages.GameStage.draw(GameStage.java:134)
at com.mygdx.game.GameScreen.render(GameScreen.java:25)
at com.badlogic.gdx.Game.render(Game.java:46)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:208)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
try using this:
textureRegion = new TextureRegion(new Texture(
Gdx.files.internal("background.png")));
if it does not work review, case sensitive, of the file name.
Edit: look that is a copy of the file, not a link, once he happened to someone so wrong
You shouldn't load assets in a constructor directly because Gdx.files is null. Either load the assets outside of the constructor or use the AssetsManager.
So i'm very new to libgdx and i were doing the drop tutorial that is at the libgdx wiki.So when i finished i got an error on line 98 at Iterator<Rectangle> iter = raindrops.iterator();
More specifically it says :
The type HTMLDocument.iterator is not genetic; it cannot be
parameterized with arguments <Rectangle>
Also in the console i get this :
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.Error: Unresolved compilation problem:
The type HTMLDocument.Iterator is not generic; it cannot be parameterized with arguments <Rectangle>
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:120)
Caused by: java.lang.Error: Unresolved compilation problem:
The type HTMLDocument.Iterator is not generic; it cannot be parameterized with arguments <Rectangle>
at com.mygdx.test.Test.render(Test.java:98)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:206)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
I really dont know why i get this error if you know the solution i would really appreciated help. Thanks for your time.
Seems like you accidentally added a wrong import!
You need to import:
import java.util.Iterator;
Instead of:
import javax.swing.text.html.HTMLDocument.Iterator;
because the class HTMLDocument.Iterator is not used at all in the libgdx drop tutorial
I believe this is because of the html project not automatically being set up properly. Maybe try this
While creating a jfreechart im getting following error and I am not sure whats the reason for it..any help??
Exception in thread "main" java.lang.NoSuchMethodError: org.jfree.ui.RectangleInsets.<init>(DDDD)V
at org.jfree.chart.axis.Axis.<clinit>(Axis.java:146)
at org.jfree.chart.StandardChartTheme.<init>(StandardChartTheme.java:227)
at org.jfree.chart.ChartFactory.<clinit>(ChartFactory.java:229)
at modules.images.Chart.createChart(Chart.java:67)
at modules.images.Chart.<init>(Chart.java:59)
at modules.images.Chart.main(Chart.java:506)
Make sure you have jcommon-1.0.0.jar (or a later version) on your classpath.