I have a fragment that displays data from APIs, but i dont want to be calling apis everytime the fragment is called.. so am making api call from a different class and and calling a method in the fragment to update UI (textViews) but am getting null exception for the textViews but data is 100% there and if i t…
Tag: java
vscode – Could not fetch model of type ‘GradleProject’ using Gradle distribution ‘https://services.gradle.org/distributions/gradle-7.2-bin.zip’
I was trying to build a gradle project but it returned with an error: I’m using vscode for this I saw some questions similar to this but they were about android studio, and I couldn’t find anything else about it. Thanks for any help. Answer the issue has been resolved on github: https://github.com…
Set elements of a java array from another class or file
I’m making a game right now and I’m trying to setup a CreatePlayer method. In the main class, I take the Player class as an object to get its variables, methods ect. The 3rd parameter of Player is the Position, which is an array. The problem I’m having is that I’m not sure how to set e…
How to count records from database and put them into List,each row represent by the letter?
I need to take values from a database and put them into a List<Long>. I made a native query but it doesn’t work correctly. Here’s a picture of the column on my database: I need to count the same statuses (“W” and “I” represent the same status but are represented by an…
Why is JScrollpane not added to JTextArea in my TextEditor?
I can’t understand why the JScrollpane won’t be added to JTextArea, is this because of some sort of layout problem? This is a text editor made by my friend, he initially made it with only AWT but I then replaced AWT TextArea with swing’s JTextArea to wrap text. Output: Edit: Thanks everyone …
Beam PAssert messes up the Row
I am exploring testing with Beam and encountered a weird problem. My driver program works as expected, but its test is failing with an error like this: And here is my PAssert code: On the last step of my pipeline, I log the element in question. This is the expected result. When I debugged the test, the proble…
How to add subnode to json file using json-simple
I create json file with the folloing code: OUTPUT: How can I add content of java map to the this json output as a new node sothat I have at the end the following output: Answer You just need to add another object of type JsonObject and it will do that And that will return the output what you want
Accessing elements inside a GraphicsContext in JavaFX canvas
I’m implementing a simple hockey game following an MVC pattern. I’m having trouble refreshing the player’s position, which I have created inside a canvas using the GraphicsContext.drawImage() method. I’m inside an AnimationTimer anonymous class, inside the handle method. The positions …
How to handle blob store url when receive from API
I have an API URL (e.g.: localhost:8080/api/blobs/download/{item-id}). The API itself will return the URL of that item in the Blob Store (for example, https://myaccount.blob.core.windows.net/mycontainer/myitem). Now I have a task that requires user to copy and paste the API URL into the browser, and expect it…
Best way to access variables from another class?
I need to access variables from another class and I have done it using 2 different approaches described below. My question is which of the two is preferable and why since both work quite nicely -or is there another better way to do it?. I have also done it using internal classes but this is inconvenient when …