goxr3plus / FX-BorderlessScene

💠 Undecorated JavaFX Scene with implemented move, resize, minimise, maximise, close and Windows Aero Snap controls.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stange NullPointerException in Line 242 BorderlessController

goxr3plus opened this issue · comments

@Typhon0 Hello my dear friend , i just notices a strange bug here :

Line 242 BorderlessController

if (m.getScreenY() > eventSource.y) {
     stage.setWidth(prevSize.x);
     stage.setHeight(prevSize.y);
    snapped = false;
}

I have no clue why that error happens sometimes but it doesn....

@Typhon0 To recreate this bug just run your "Drag Me Example" program. Resize the very top to the highest it can go so that it maxes the height of the program with the screen height. Then try to move the move the scene with the move node.

I added some null checks on x/y values of eventSource and prevSize for some if statements. Although if you initialize these variables better in setMoveControl you could probably avoid the null checks. If I understood your project better I would dive more into it but I feel like this is a quick 5 minute fix for you when you know the project well.

Although with the null checks I added it removed the snap.

@bwcsemaj You are more than welcome to pull request your solution , we will discuss the code together and i will accept it . The code for this project is not that big .... :)

Please post your solution , better a temporary one that nothing :)

I would make a pull request but what I added at the time wasn't very good code imo. Basically the problem is he is using Double objects for his x/y values for his Delta object (which is essentially just a Point2D class) and isn't initializing them at all. He also made the x and y values public which I disagree with (really the whole Delta class should get replaced with Point2D class; I also don't agree with using null as an option those variables could be). He then obviously accesses the x and y values and does comparisons thus nulling out. What I did was just null checked the values he was using (either x/y or both) before the comparison so if it was null it wouldn't go any farther if that makes sense. I would run the program, null out, add a break point and check which value was nulling out (again later on I found out it was just eventSource/prevSize objects) and added null checks (before the null checks I tried just initializing with 0s but that didn't work out well).

After my dumb fix I implemented BorderlessScene into my project and ran into more issues thus just giving up on trying to use the library (I know not very nice of me but I'm on a time crunch). I ended up just deleting my local respo of the library and moved on so to speak.

Tomorrow if I get time I will relook over the library. Obvious better way of going about this is just initializing the variables with actual values from the start than using null checks (but I didn't know what values to use etc at the time).

Very happy to hear that :) :) :) :) !!!!