CheerpJ missing functionality of original Jar file

I am trying to get my java swing projects in the browser, but the program is not working fully (it works as a JAR file just fine on Windows 11). It's a minesweeper clone I made that uses an array of JTextFields and uses repaint when updating colors, otherwise changing text to match an array that is the key when revealing a space. However, when using CheerpJ, it doesn't update a clicked tile space and sometimes just makes the game end (I have a checkWin() method). Additionally, a secondary game (there's a replay functionality) doesn't take. I downgraded the JAR file to run on Java1.8 (I'm using Eclipse IDE) and my program is less than 12 KB (it has 2 classes and one has 1110 lines with whitespace included).
10 Replies
apignotti
apignotti9mo ago
To help you we need to be able to see the test cases. At the minimum please upload them (including the HTML page) to a publicly accessible URL, for example GitHub pages). If you can provide a minimal test case we can look at the problem immediately, but if we need to debug larger apps it might take some time before we can allocate a developer to debug the problem. If you can extract a minimal test we will be able to debug much, much sooner.
Elizabeth
ElizabethOP9mo ago
Here is the GitHub link: https://github.com/Big-Sad/Site-for-Help I'm unfamiliar with GitHub, so please let me know if I need to change anything to make it more accessible. I'm not sure how to display a test case other than describe it. I would input 7 in both dialog box prompts and then when I click any tile, it doesn't load properly.
apignotti
apignotti9mo ago
Can you provide precise instructions on how to reproduce the problem? How many rows and columns, what situation is not working as intended? Be as precise as possible
Elizabeth
ElizabethOP9mo ago
If there needs to be more clarification, let me know. Using Visual Studio Code, I run a local server using the add-on "Live Server" by Ritwick Dey. After loading the web page's HTML, CheerpJ opens Minesweeper. In the middle, the dialog box prompts for a "Number of Rows" and a "Number of Columns". If you input 7 for "Number of Rows" and 7 for "Number of Columns", a 7 by 7 grid appears. Clicking any box of the grid makes the clicked box turn a light blue momentarily. Nothing happens afterward. If the same box is clicked 3 consecutive times, the entire board will reveal blank spaces populated by "bombs" and a dialog box saying "Congratulations! You Won! Do you want to start a new game?" will pop up. Clicking the "yes" option will recreate the initial prompt of inputting rows and columns. However, when clicking "OK" the window everything except for the header and the menu bar is blank. What should happen when a box is clicked, a random shape of connected boxes will appear with numbers at the border (Mimicking the classic "Minesweeper" game). Additionally, there should be a custom graphic that is a small, pixelated rectangle (longer horizontally than vertically) within the menu bar aligned to the right-hand side with a flag on the left and a bomb on the right. It can toggle between 2 states, one with the word "FLAG spelled out, and the other with the word "BOMB" spelled out. However, this graphic does not appear at all.
apignotti
apignotti9mo ago
The problem should be fixed with the following build: https://cjrtnc.leaningtech.com/3_20240320_461/cj3loader.js Thanks for reporting this
Elizabeth
ElizabethOP9mo ago
Thanks for the help. However, I have a custom png icon (with an itemListener) that doesn't show up at all. It is supposed to appear in the top right in the menu bar. Clicking it allows for mode toggling.
apignotti
apignotti9mo ago
As far as I can see it's not a PNG It's a unicode char CheerpJ has very extensive support for most languages, emojis and symbols. But that specific symbol is not supported from Google's Noto fonts, which are the ones CheerpJ uses I see the application tries to load pngs for the "bomb" and "flag" symbol, but they come from hardcoded path in a windows system, which is not correct
Elizabeth
ElizabethOP9mo ago
I am unaware of how to "back out" of a folder with Java since the images are stored in the src folder but the class files are stored in the package. Would it be easier to move the files somewhere else or is there a way to reroute the way I retrieve the images?
apignotti
apignotti9mo ago
In Java, the simplest solution, is to store the images in the jars. It's a very common problem and you'll find plenty of information on the internet.
Elizabeth
ElizabethOP9mo ago
Thank you so much for all the help. Everything seems to be working now.
Want results from more Discord servers?
Add your server