Barry A. Burd

Articles & Books From Barry A. Burd

Article / Updated 10-13-2017
Before you can jump into Java GUIs, you need to install JavaFX and Scene Builder. GUI programs have two interesting characteristics: GUI programs typically contain lots of code. Much of this code differs little from one GUI program to another. GUI programs involve visual elements. The best way to describe visual elements is to “draw” them.
Article / Updated 10-13-2017
Say that you’re sending a friend to buy groceries. You make requests for groceries in the form of method calls. You issue calls such asgoToTheSupermarketAndBuySome(bread);goToTheSupermarketAndBuySome(bananas);The things in parentheses are parameters. Each time you call your goToTheSupermarketAndBuySome method, you put a different value in the method’s parameter list.
Article / Updated 10-13-2017
Before you jump into Java GUIs, there are a few things you should know. Java comes with three sets of classes for creating GUI applications: The Abstract Window Toolkit (AWT): The original set of classes, dating back to JDK 1.0. Classes in this set belong to packages whose names begin with java.awt. Components in this set have names like Button, TextField, Frame, and so on.
Article / Updated 10-13-2017
When I was a young object, I wasn’t as smart as the objects you have nowadays. Consider, for example, the object in the code below This object not only displays itself, but it can also fill itself with values.importjava.util.Random;importjava.text.NumberFormat;import static java.lang.System.out; classBetterAccount {String lastName;int id;double balance; void fillWithData() {Random myRandom = new Random(); lastName = "" + (char) (myRandom.
Article / Updated 10-13-2017
When you start learning object-oriented programming, you may think that this class idea is a big hoax. Some geeks in Silicon Valley had nothing better to do, so they went to a bar and made up some confusing gibberish about classes. They don’t know what it means, but they have fun watching people struggle to understand it.
Article / Updated 10-13-2017
A String is a bunch of characters in Java. It’s like having several char values in a row. To read a String value from the keyboard, you can call either next or nextLine: The methodnextreads up to the next blank space. For example, with the input Barry A. Burd, the statementsString firstName = keyboard.next();String middleInit = keyboard.
Article / Updated 10-13-2017
The Java program below takes the user’s input and echoes it back on the screen. This is a wonderful program, but (like many college administrators) it doesn’t seem to be particularly useful.Take a look at a more useful application of Java’s String type.import java.util.Scanner;import static java.lang.System.out; class ProcessMoreData { public static void main(String args[>) {Scanner keyboard = new Scanner(System.
Article / Updated 10-13-2017
To write the Java program you see below, you need a loop — a loop that repeatedly asks the user whether the importantData.txt file should be deleted. The loop continues to ask until the user gives a meaningful response./** DISCLAIMER: Neither the author nor John Wiley & Sons,* Inc., nor anyone else even remotely connected with the* creation of this book, assumes any responsibility* for any damage of any kind due to the use of this code,* or the use of any work derived from this code,* including any work created partially or in full by* the reader.
Article / Updated 10-13-2017
You can make an enhanced for loop to step through a bunch of values, including an array’s values. Let’s take a look at an enhanced for loop that steps through an array’s values.To see such a loop, start with this code. The loop looks something like this:for (int roomNum = 0; roomNum < 10; roomNum++) {out.println(guestsIn[roomNum]);}To turn this into an enhanced for loop, you make up a new variable name.
Article / Updated 10-13-2017
The Java code you see below illustrates some pithy issues surrounding the input of data. For one thing, the program gets input from both the keyboard and a disk file. (The program gets a room number from the keyboard. Then the program gets the number of guests in that room from the occupancy file.) To make this happen, this program sports two Scanner declarations: one to declare keyboard and a second to declare diskScanner.