• 0

[Java] Any good swing website guides?


Question

So I'm mainly studying swing in java now and don't think I could feel like quitting much more, I need some serious help here because I feel like I literally haven't got a clue at what I'm doing whatsoever.

Are there any websites with plenty of examples but basic that use GUI, Swing... Every time I search for help every single website overcomplicates it ridiculously that it just confuses me and want to throw in the towel or they're in the cmd console (i.e. lack the gui).

I find what helps myself learning is when I can sort of put the pieces together, i.e. I have smaller examples and I figure how to build them up and put them together to make something bigger. Obviously this isn't how I learn completely, I try use as many text-books as I can - our recommended course one Java - How to Program by Deitel feels like it skips whatever valuable point I'm looking for. Any recommendations there from anyone?

Thanks, i'm pulling my hair out over this.. it's driving me insane

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

As Thom said, swing really is a HUGE mess. I never found a really in depth guide online, but was able to get a lot of useful information out of the Oreilly Java Swing book. It's fairly long, but it goes really in depth into the inner workings of swing.

Link to comment
Share on other sites

  • 0

Swing really isn't a horrible thing.

It's based on the Observer design pattern. And the key thing to realize is that your code is "triggered." So that, once you start up some program with swing you cannot trace line by line the code it executes. This is what confused me the most when I was learning.

Swing actually creates a thread in the background (the Event Dispatching Thread, EDT) which sits and waits for user input. The code you've written may or may not ever get executed. It depends solely on the user's commands. If the user presses a button, the EDT triggers the code block you have attached (via an ActionListener).

Once you understand this, the only hard part is figuring out what component to use where and what events are triggered by what. Try out NetBeans. It has a GUI creator that is very useful for creating static (I mean, non-changing) GUIs.

PM me if you have specific questions.

Link to comment
Share on other sites

  • 0
Java Swing is an overengineered mess. Especially if you don't have much experience in programming languages to begin with, it can be frustrating to work it out.

Take a deep breath and try following the official Swing tutorial : http://java.sun.com/docs/books/tutorial/uiswing/ :)

I agree. I hated Java just because of the way we had to create GUIs with it back in college and I've always felt Java is slow compared to other languages. It has its purposes but it's not something I'm interested in coding with.

Anyways, to the OP, good luck with your work. I suggest following the tutorial as well.

Link to comment
Share on other sites

  • 0

Good lord. I haven't used swing in years. I used it a little in high school and did pretty well with it, and I had 1 course at college that used it, but nothing since. I don't have my old note handy, but I could try to help you if you have any specific questions.

As dontocsata already mentioned, the key concept is that you assign triggers (ie. add these two numbers, display this to the screen, ect) to events (ie. this button is pressed, some text is entered, ect.). The only other concept that you might have trouble with is containers, but that's pretty much what the name implies.

Link to comment
Share on other sites

  • 0

Many thanks for the replies, really helpful. The assignment's in now, not very good but it's done and out of my hands at least for now, there's more assignments to come anyway so sure i'll still have some issues.

So that, once you start up some program with swing you cannot trace line by line the code it executes. This is what confused me the most when I was learning.

That makes a lot of sense, I was really used to that with Java in the cmd prompt you can almost translate each line. I've just been using TextPad, we've been recommended to really try Eclipse since the start of swing this year, though I either didn't set it up correctly or I find it a bit too much. As for netbeans I'll definitely try that, we were given Netbeans with Textpad last year at the start of our course though I don't recall ever once being told to use it - I stumbled across it on some tutorial and it looked really helpful but was a bit too far into my assignment, I'll give it a go though now i'm reminded!

thanks again for all the useful links + help, really appreciated guys!

Link to comment
Share on other sites

This topic is now closed to further replies.