RUVIDEO
Поделитесь видео 🙏

Java Swing Components | Graphics | Timer

Here's an appetizer for you!
Learn the basics and explore the fundamentals. Don't be afraid! I believe that you can make this Bouncing Ball program better.

▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

GitHub ► https://github.com/Philiks/code-with-...

Oracle's Citation ► https://docs.oracle.com/javase/tutori...

Java Tutorial Series ► https://www.youtube.com/playlist?list...

▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬


Why is the JFrame not at the center at 8:30 and what's with the "position" of the code?
- Well, there are two things [methods] that caused this behavior the setLocationRelativeTo(null) and pack(). The thing is, we position the JFrame at the center then pack() changes the JFrame's dimension so the JFrame failed to change its location after we have changed its size.


So why do we have to reposition all the codes in JPanel?
- To make the code look cleaner. That's it.


Is Math.random() broken?
- No, but I am stupid so I misused to hahaha. Well, thankfully Java have 2 RNG and luckily I know how to use one of those two properly.



Oh you want to learn why I asked you to change the ball's initial position?
- Well, it's simple. The ball would bounce on the same path if the ball is at the center. This is due to the ball's dimension at JFrame's dimension. It's the ball's and JFrame's fault and not my stupidity ok (?)



What happened to the skinny ball to the end?
- Like I said in the video, I just change the stroke's thickness and in order to do that, I have to use Graphics2D and consequently convert my setColor() and drawOval() to Graphics2D. Additionally I added an inner oval with a darker color to have a "body" plus I did some tweaking to make the ball look like a basketball.

So now that you've learned how to bounce a ball, what's next?
- In the next video for this series, we will do ________ visualizer.

Thank you for watching!

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Java Swing Components | Graphics | Timer», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.