-
Replied To a Post in Keyboard GUI
The integer values you need for the keys are those defined in the KeyEvent class. Otherwize looks OK so far. -
Replied To a Post in GA Elitism values strange
Without actual code one can only make wild guesses, for example: When you copy the populations is that a shallow or a deep copy? Maybe its a shallow copy and … -
Replied To a Post in Array of object
Java arrays start wil element [0], so element [1] is the second element. A new array of objects will initially have all its values as null. If you haven't initialised … -
Replied To a Post in Trying to avoid AWT classes in Swing GUI
Agreed. BufferedImage was OK as it was, so there was no need to replace it. It's still the one to use. -
Replied To a Post in Array of object
Your use of Arrays.toString is correct (no need to loop) it converts each element of the array to strings and lists them all. The problem is that the first element … -
Replied To a Post in Array of object
"It doesn't work" tells us nothing. Would you take your car into the workshop and just say "there's something wrong with it" and expect the mechanic to fix it? Did … -
Replied To a Post in Keyboard GUI
Yes, yes and yes -
Replied To a Post in Keyboard GUI
A good example of why you shou;dn't start with the GUI details! Think about the heart of the program. When the user types a key you want to make changes … -
Replied To a Post in Arrays
Maybe the code isn't of the highest professional standard, but honestly it's not particularly messy either. Good enough for an early-stage learner. So what EXACTLY do you need help with? -
Replied To a Post in Keyboard GUI
Given that the buttons don't actually do anything, or have any data associated with them, I can't see any need for anything more than a vanilla JButton. Oh well, I … -
Replied To a Post in Keyboard GUI
OK - I thought the idea was to be able to type on the screen? If it's not going to respond to touches then why use JButtons? Anyway - to … -
Replied To a Post in Keyboard GUI
I would create a class, something like... class KeyButton extends JButton implements ActionListener { char normalChar, shiftedChar; int width; static int HEIGHT = 20, DEFAULT_WIDTH=20; public KeyButton( char normalChar, char … -
Replied To a Post in Keyboard GUI
Thinking about this a bit more... it's a very interesting exercise. As soon as you think about the modifier key(s) it has great scope for good or bad design. It's … -
Replied To a Post in Keyboard GUI
> so rather than GridBagLayout, do you think that GridLayout is a better idea? Apart from rows 2/3 the keys do not line up vertically, so the whole thing is … -
Replied To a Post in Keyboard GUI
Looks reasonable to me - except I don't see why you have a panel (line 5) with only one thing in it - just add the text area directly. For … -
Replied To a Post in event handlers: anonymous inner class or not
I just hate those if else if handlers. How about a reusaable parametised inner class class FontResizer implements ActionListener { int delta; FontResizer(int delta) { this.delta = delta; } public … -
Replied To a Post in event handlers: anonymous inner class or not
Agreed, provided the reason for using for several components is that there is a lot of commonality between them (see example in previous post!). In beginners code we often see … -
Replied To a Post in JavaFX and Object Oriented
I don't have alot of time at the moment, so here's a short version. The only thing that should be static in this app is your main method You just … -
Replied To a Post in event handlers: anonymous inner class or not
The AIC approach gives you a separate handler for each event, which is typically what you want. You use a "normal" inner class when you want to pass parameters into … -
Replied To a Post in JavaFX and Object Oriented
You are having problems because you are using an OO language as if it was purely procedural. The big clues are all those static members and classes whose names are … -
Replied To a Post in JFrame and JPanel
Perfect! -
Replied To a Post in JFrame and JPanel
Yes, you can put components directly into a JFrame (well, actually there are some panels that are part of every JFrame, and one of those is where your components are … -
Replied To a Post in How to attach output from the jbutton to jtext field?
That ignores eveything from our last few posts. Go back and read them all again please. -
Replied To a Post in How to attach output from the jbutton to jtext field?
No, Person isn't an interface, so you can't implement it. Person is just another class like String or JFrame, except you wrote it not Sun/Oracle. Provided its in the same … -
Replied To a Post in How to attach output from the jbutton to jtext field?
No, it was the list that you had in your previous code. Adding items to a JList goes like this: JLists keep their data in a `ListModel` (that's defined as … -
Replied To a Post in Problem with deleting a record inside an SQLLite database in Android Studio
It would help if you gave some better info than "it wont let me". If you have a compiler or runtime error message post the complete message plus the actual … -
Replied To a Post in How to attach output from the jbutton to jtext field?
Here's a very simple example. Experiment with somethimg like this: // container for info about one person class Person { String name; int age; public person(String name,int age) { this,name … -
Replied To a Post in Help with the pet store
Well yes. That makes total sense when you are designing and maintaining the while hierarchy. That's why I think Java needed a visibility for members to subclasses only. IMHO the … -
Replied To a Post in How to attach output from the jbutton to jtext field?
OK It looks like you should have a class that encapsulates a Parcel with all its data fields. That's how you implement a "storage/container" in Java. You can create an … -
Replied To a Post in How to attach output from the jbutton to jtext field?
Sorry, I don't understand what you are trying to do. What is the purpose of your list of JTextFields? How do you imtend to use that? -
Replied To a Post in How to attach output from the jbutton to jtext field?
Line 4 is OK, but line 2 looks dodgy `(count > 0) `is a boolean expression but I guess `jTextFieldParcelID` is not a Boolean, so they are never equal, so … -
Replied To a Post in How to attach output from the jbutton to jtext field?
Yes, just convert the int to a String. Shortest way is string concatenation because that converts automatically, eg `""+count` ... but some people dislike that because it's a bit obscure, … -
Replied To a Post in How to attach output from the jbutton to jtext field?
Use the JTextField's setText method to display the clicked count. You can do that as part of your jButtonScanActionPerformed method -
Replied To a Post in Help with the pet store
"There is an error" is a useless answer. What error exactly, in what code exactly? Anyway... jwenting is right about private variables, but I totally disagree with him about how … -
Replied To a Post in Memento design pattern in Java
Then why not code a test case that looks like that in your Caretaker, rather than the different sequence of events you have progrmmed in lines 40-49? -
Replied To a Post in Help with the pet store
What do you mean "cannot use"? What exactly is your question? -
Replied To a Post in Memento design pattern in Java
Create a Memento before each time you add or remove. Use the latest Memento to roll back the latest change. The WikiPedia article on memento design pattern has an example … -
Replied To a Post in Get name of month from integer
When you have the month number as a String you can convert that to an Integer using the `Integer.parseInt `method (see API doc for details). Then you can use that … -
Replied To a Post in Properly using a Canvas [Java]
Excellent! A while ago I did a test/demo program using the simple architecture above. It has hundreds of balls bouncing around and bouncing off each other, with full spherical bounce … -
Replied To a Post in Properly using a Canvas [Java]
It looks like you are fighting the Java graphics system rather than working with it. Before getting into buffer strategies, just try the recommended (flicker free) mechanism... Override paintComponent for … -
Replied To a Post in Properly using a Canvas [Java]
Swing components are double buffered by default, unlike the old AWT components that make you do it. If you place a canvas with some more complex buffering strategy inside a … -
Replied To a Post in Properly using a Canvas [Java]
Useful in what ways? -
Replied To a Post in Properly using a Canvas [Java]
Why? Canvas is an old AWT component that you would use in an old AWT Frame. Forget it, and use a JPanel. -
Replied To a Post in Fractions
In that case please explain it to me, because I'm still confused. n isn't the result of anything, it's an arbitrary value passed in as a parameter. And what's wrong … -
Gave Reputation to David W in Dealing a deck of cards (w/ 4 players) without duplicates
An other way to approach your problem is to 'huffle the deck' before dealing it out ... Take a look: /* 52Cards.c */ /* You can find file "readline.h" at: … -
Replied To a Post in Dealing a deck of cards (w/ 4 players) without duplicates
Before going any further I urge you to look at David W's post again ... creating a full deck, shuffling it, and taking cards from it. His approach is going … -
Replied To a Post in Fractions
That's a good question. All the definitions of mediant that I found in a quick google had no use or meaning for such a parameter. Are you sure that method … -
Replied To a Post in Crossing English Words- in java
I posted some pseudocode earlier that gives you the logic for printing crossed words. Try to convert that into Java and see how far you can get. I'm on holiday … -
Replied To a Post in how to spot logic errors
Hi Dennis Yes, you're right. char types in Java are numeric Unicode values, so it's valid to compare them with any other numeric type, but '0' is a char constant … -
Replied To a Post in Java, Constructor that MUST EXPLICITLY call super
Whether you need a parameter isn't the point. This is the only way I know to do what you asked. Every constructor must start with a call to a superclass …
The End.