Monday, 17 October 2011

Java: More GUI Stuff!

So it turns out, in discovering and using the Netbeans GUI creator, I skipped like, a bajillion pages in the textbook, which are all about bringing up buttons and setting up events, and the proper way to put things together (A jFrame being the bottom level, to hold everything, then a jPanel for each section on the Frame and so on.). So uh. I'm kinda out of the GUI chapter, save a couple of examples!

I guess we'll do those (its some relatively cool stuff), until someone in the comments section has a specific request, or we can just move on to multi-threading and such, which will be the final thing to learn about.

Anyway, for now, we can have a simple text editor! Let's start off by designing it, visually.
Let's keep it basic. Making a new project for this would be preferable, for the sake of organization, and then a new, non-Main.java file to work with. We'll need at least 5 buttons:


Load
Save
Cut
Copy &
Paste


Place a Panel to hold everything on the Frame, in which, you'll want another 2 panels, 1 for the buttons, 1 for the text area. Or whatever, design it as you wish. In the text area, you should first fill it with a ScrollPane (Swing Containers), THEN you can put the TextArea (Swing Controls) in. This'll be, predictably, so you have a scroll bar!
TL;DR: Design your shit. Umbrella panel, then a panel for buttons, and a panel for text. In text panel, scroll pane. Inside scroll pane (found in Swing Containers), put a TextArea in (found in  Swing Controls).

I'll leave you to design as you wish for the rest of the day, here is my, er, masterpiece?



So it ain't much to look at, what do you want from me? I'm not a designer! Use your imaginations to make your own, and let me know if you'd like more added to it, or something taken away (hah), or if you have any problems!

Further, suggestions for other small projects after this to work through publicly would be great!

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. 

3 comments:

  1. I know it has nothing to do with this. But would you teach us how to make simple games with java?

    ReplyDelete