Saturday, 15 October 2011

Java: Core GUI Concepts II - Example Program (The easy-ish way: Visuals)

Okay, I think I got this worked out! Let's have a shitload of screenshots!

Let's start off by making a new file in Netbeans. But instead of the regular Java file, scroll down to the Swing GUI Frame, then select JFrame. This will, predictably, give you a JFrame to work with. Fun times.

There, you have your frame, and on the right hand side should appear a bunch of options to add new components. If not, either hit Ctrl+Shift+8, or go into Window > Palette

Right click the frame, then hit properties. This is the only way I could find to modify the title bar's text. There's also some other neat things you can play around with here, such as changing how the cursor looks in your window!

From this point, you probably want to make the frame smaller. Not that much space needed, after all. And now, in the palette, pick the Label and Button, and place them accordingly. You'll probably want to use the dotted lines that come equipped for centering and such. Otherwise, when increasing the window size, it could get pretty weird. Right click each component, and edit text to suit your needs. You can go into the properties for the label to change text alignment to make the Hello/Goodbye look less weird.
TL;DR: Resize + add components. Use properties and edit text (r-click) to suit your needs.

This is what you should have right now! So yeah, it's taken me a strangely long amount of time to work this stuff out, so I'll give ya'll a day to play around with the visuals and whatnot, and tomorrow, I'll work on the functionality.

I know it seems weird that the easy method will be spread over 2 days while the tough method took one, but hey, there's lots of easy stuff for you to play around with :D (Also, I'm pooped.)

So that's it for now..Questions welcome! Comment, follow, subscribe, share etc, and see you tomorrow!

And as part of a shameless plug for a friend, if you're interested in classic movies/books/music, visit his site here (fixed), and feel free to throw loads of criticism at us.