Woop, well we have everything in place, so the only things left to do are "New" and "Close", put them in a menu bar (along with everything else), and give them shortcuts! After today, we'll start work on Threads, which will allow us, hopefully, to work on some of the simpler games.
An issue I don't feel like working on is when you hit new/close/load, an option to save doesn't come up. Also there's no Save vs. Save As. But that's okay, since I wasn't planning on this replacing Notepad anyway, and its more of a matter of building it than learning anything new.
Here's the new and close methods:
Showing posts with label AWT. Show all posts
Showing posts with label AWT. Show all posts
Thursday, 20 October 2011
Wednesday, 19 October 2011
Java: Completing the Text Editor Functionality II
As per the comments a couple days ago: Yes, we absolutely can get to simple games, but to do that, we need to learn about threads! So I'll do that right after this text editor is done! I suppose turn based games require it less, but still.
Okay, let's get to finishing this thing. Since load() was just a version of reading files, it follows that save will be a similar version of saving (durr) them. Keep in mind that our finished project will be very rudimentary, and you'll probably still be better off using notepad and stuff, but its still functional, right?
I changed a line in the code for load, when initializing the JFileChooser. It is identical to the initialized JFileChooser in the following:
Okay, let's get to finishing this thing. Since load() was just a version of reading files, it follows that save will be a similar version of saving (durr) them. Keep in mind that our finished project will be very rudimentary, and you'll probably still be better off using notepad and stuff, but its still functional, right?
I changed a line in the code for load, when initializing the JFileChooser. It is identical to the initialized JFileChooser in the following:
Tuesday, 18 October 2011
Java: Completing the Text Editor Functionality I
Well, we have our text editor, which looks like:
Now, we need to add functionality to the buttons, but we want our methods of save/load etc. to be just that, their own methods, which the buttons call, so first, we need to actually make the methods, and have the action listeners come in later!
Let's go in order, starting with Load. This is some new material, so pay attention: JFileChooser is what we're using. This took me a while to figure out, too, so we`ll only be doing Load today, Save will be easier with this knowledge, so I can probably do the remaining 4 tomorrow!
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.
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.
Sunday, 16 October 2011
Java: Core GUI Concepts III - Example Program (The easy-ish way: Functionality)
I feel that I should note this GUI builder isn't part of the textbook. I just looked at the generating of code and thought "Fuck this, there's gotta be a better way!" And then there was! Also, post on Sunday since I had that day-off earlier in the week.
Anyway, now that we have the visuals more or less done, we should work on functionality. First off, we want to get out of the design tab, and move into the code tab, like so:
Anyway, now that we have the visuals more or less done, we should work on functionality. First off, we want to get out of the design tab, and move into the code tab, like so:
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.
Friday, 14 October 2011
Java: Core GUI Concepts I - Example Program
Well, good to know that TL;DR is a hit! Moving on, GUIs themselves are complicated to teach beyond "Here's the libraries, get to it", so we'll start off with an example program! This should hopefully give us an idea of how certain aspects are used and whatnot.
The example we'll be using is just a window with a button. The button will toggle between 2 text messages, "Hello" and "Goodbye". It's surprisingly complex, so I'll only be doing this for example purposes, so you can see how the code works. Tomorrow, I'll be recreating the program the easy way (I hope), so don't fret if this is ridiculous. Here is the end result:
The example we'll be using is just a window with a button. The button will toggle between 2 text messages, "Hello" and "Goodbye". It's surprisingly complex, so I'll only be doing this for example purposes, so you can see how the code works. Tomorrow, I'll be recreating the program the easy way (I hope), so don't fret if this is ridiculous. Here is the end result:
Thursday, 13 October 2011
Java: GUI Introduction
Well, the voters have spoken! GUIs first it is. Which is good, I didn't have much of a stomach for a day of gaming. Ended up going for a "jog". Turns out I'm much less fit than I remember! So I just played Men of War:Vietnam before a whole bunch of TF2 (Which I also suck at).
Feel free to read the TL;DR: sections at the end of sections to get the gist of it and move on. :D I might do them more often, just 'cause I know my posts are often long and could be summed up more concisely.
Anywho, let's get on with the GUI stuff. As most of you know, the user interface of a program is what the user sees and interacts with when trying to use a program. There are two fundamentally different types of user interface. Thee's the command line interface, which is how we'd be using our programs so far, if they weren't processed in Netbeans:
Feel free to read the TL;DR: sections at the end of sections to get the gist of it and move on. :D I might do them more often, just 'cause I know my posts are often long and could be summed up more concisely.
Anywho, let's get on with the GUI stuff. As most of you know, the user interface of a program is what the user sees and interacts with when trying to use a program. There are two fundamentally different types of user interface. Thee's the command line interface, which is how we'd be using our programs so far, if they weren't processed in Netbeans:
Labels:
AWT,
containers,
events,
GUI,
Java,
listener,
panel,
Swing,
User Interfaces
Subscribe to:
Posts (Atom)