Advanced Java: Swing (GUI) Programming Part 5 -- Event Handling

preview_player
Показать описание
-------------------------------------------------------------------------------------------------------------------------------------------
A tutorial on how to implement custom events and how to deal with events generally in Java Swing applications. This tutorial shows you how to wire up your Swing app, so that the different parts of the application can communicate with each other using events routed through a central controller object, helping to prevent your app becoming a rat's nest.
--------------------------------------------------------------------------------------------------------------------------------------------
Рекомендации по теме
Комментарии
Автор

Hi John, I am a beginner in Java making my way through it:) I really like your courses because you not only explain it in a perfect way but that "peacefull" commentary with a classical intro and outro takes away any burden from a busy day and keeps me really concentrated to the topic. In addition, you discuss only as much as a human can absorb in those 15 minutes. Thanks:)

eriksabol
Автор

Finished your beginner videos (about a week's worth) then looked at this, and it was like rocket science down low. Still was able to see a path forward, and a finished product was a great help. This, the last of this series, was a real "blast-off". Great tutorial, and thanks for minus the piano music :)

TransitionsLA
Автор

Hi, I am a beginner with Java, but I would say that you can save the JTextArea entries in an ArrayList and than let the JTextArea just display all elements from the Array List (or just append the last entry based on event). That way you can easily delete the last entry from an ArrayList on demand and reload the JTextArea again.

eriksabol
Автор

really helpful videos and decent mic quality, plus your playlists all cover exactly what i'm focused on learning (java, sql, c++), subbed and intending to watch every video in each of your playlists asap. thanks a bunch for all the work you put into helping others

qwertyqwert
Автор

@Janac Thanks for the feedback; it's really useful to know. I was really rushing to cover a complete example in 15 minutes, and this was about my 2nd or 3rd attempt. There's some example code on my site if it helps.

caveofprogramming
Автор

Yeah, your Java has to be pretty good to get through this I think! I actually plan to make a simpler version of this as soon as I've obtained a better mic. This stuff is probably overkill for most applications --- you can set up a simple "callback"-type mechanism that does the job with just one interface and a few lines of code.

caveofprogramming
Автор

Your the bomb! I love your tutorials! I don't have a teacher for java but im learning it in school, and i'd like to thank you so much!

MrPowerYak
Автор

Hi Richard, I'm not sure if that's a good description of it or not. The stuff I go through here is known as the "observer pattern" --- it you look at my channel, you can find three videos on it that break it down a lot more than this video. This video also goes over some unnecessary detail really -- it was my first stab at explaining this. The thing is that if you call one components's methods from another, those two components are permanently intertwined, and not very reusable.

caveofprogramming
Автор

In this app that would be fine, but as your program grows in complexity, it tends to become unmaintainable. So the idea is to try to route all events through a central place. Having said that, this video tries to fit in much too much to 15 mins and the solution I present is overkill in the context ... I intend to remake it very soon, giving a variety of solution.

caveofprogramming
Автор

Perfect Swing Series exactly what I've been looking for. Clear and precise this series will help me alot. Thx's

MikesonStudentSD
Автор

An excellent tutorial-series on java swing . Mastered the basics within an hour. Thanks a lot! and keep up the great work..

satyakichakraborty
Автор

very clear and good approach for event listener.

teoconuong
Автор

getListenerList() just returns objects of type "Object". But these objects are really various kinds of listeners, depending on what you added to the list. So you have to cast to the correct type so that you can call specific methods of the particular type of listener. Mind you, I keep meaning to remake this video ... it would be simpler not to use this listener list thing at all but just to use a reference to the listener.

caveofprogramming
Автор

It looks complex, but if you practice adding event listeners to buttons, you'll start to see what bits of code you need to create your own event listener. This video is unnecessarily complex though -- I'm demonstrating the "official" way of doing it, but really you can do it more simply (see my newer Swing course!)

caveofprogramming
Автор

Mr. CaveOfProgramming:

Where is tutorial 6!?!?! These tutorials are phenomenal!!!

robl
Автор

OMG this video series is exactly what I needed!

milesdavidsmith
Автор

I think it was impossible to explain it well in 15 min video. Normally I can follow along but with this tutorial I was kinda lost after 8 minutes. It was like one unexpected thing followed other. There is something to learn from it but I enojoyed your other vids more. Still I think you are doing a great job.

marekbugiel
Автор

Well, it compiled & ran first go (thank goodness)- but I don't really understand what I did! Off to try the 'Mastering Java Swing' series methinks. For all of them grumbling below, a) it does say "Advanced Java" in the title, so go figure, b) its good to be, uhm, humbled (in my case on this one!) as it shows you where your limits are & what to brush up on, c) these are ***Excellent*** tutorials, and whaddayou want for free?
Although I'm a bit stuck here (for the first time in about 15 vids), thank you John for all your excellent work.

SlowPersuit
Автор

Thanks for the tutorials, they've really helped me understand java gui a lot better. I learned a bit about events too!

Delfofthebla
Автор

I cover various options along these lines in the full course. Yes, you can download the course if you subscribe too. Best way is to use a CardLayout to switch views. You could alternatively just create a new window and set the old one to invisible, but best practice is to stick with one window and just change the view in it.

caveofprogramming
welcome to shbcf.ru