I did not have a problem with the first two issues.
Can you be more specific about the other two issues?
The value of dy0 is 3 in the posted code. What is different about how the posted code runs when you change dy0 to 1?

You need to try debugging the code by adding printlns to show the values of the controlling variables so you can see where your logic is wrong. If the y value for where the elevator stops doesn't align with the y value of the top of the elevator, you need to print out there values to see what the problem is.

Sorry, I think I fail to give a proper thought to my questions that I'm asking.

For the 1st and 2nd issue, the first button "F8" is slightly off align with the first line. If you re-size the window, it is possible to make the button align with the first line. I do not know if its my laptop issue, i do know that some people doesn't have my alignment issue.

Ignore the 3rd issue.

4th issue, my idea was that the lines are being drawn according to the height of the button on the left, thus the last line should be at the end of the panel. But when i setBackground(Color.YELLOW), it is obvious that the yellow overshot the last line. When you re-size the window, the yellow background just overshot even more.

5th issue, the vertical line draw at the middle of the elevator overshot the elevator area. I had to add "+ 1" at line 146 g.drawLine(xco + (width / 2), yco, xco + (width / 2), (yco + height) + 1) to remove the overshot. Can explain to me why is it so ?

6th issue, when the elevator is coming down example, from level 4 to level 3, when the elevator if halfway between level 4 n level 3, press the "F4" button, and the elevator stops.

My suggestion is to add printlns to display the values of the variables as they change to see why your logic is not working the way you want.

For the yellow to not extend past the bottom of the buttons on the left, try changing the layout manager so the buttons are in the same container with the yellow object so their bottoms are on the same horizontal line.

How about the alignment issue ? yours fit in perfectly ? is there any explanations to the off alignment I'm facing ?

The alignment issue i facing :

If i change the layout for the button , how do i make the button vertically place? actually i'm only allow to use what's has been taught to us, which is grid, flow, border. Grid layout is the best way to do it. is there other alternatives ?

Have you tried making the floors with the elevator separate components that correspond to the buttons instead of having it be one large component that you draw lines on?
The trick would be drawing the elevator over the top of the floors as it went from floor to floor. Don't know how to do that.

1st and 2nd issue has been resolved. I believe I fail to install my IDE correctly which cause this issue, I went to re-install and the alignment now went back to normal.

4th, I remove setBackground instead I use fillRect to draw my background and set to yellow. Now my last line and background is tie together, just that the buttons panel is 1 pixel shorter than my elevator panel.

I'm still working on the 5th and 6th issue.
I did printout the bounds of the components. the height is 53 and width is 47.
But i don't get it why the vertical line is 1 pixel longer than the elevator itself.
As for the algorithm for the elevator simulation, I still have no clue on solving the halfway stopping