15
votes
Accepted
Detecting Tiles in Java
The entirety of the if/else statements are redundent if we consider that if we divide the current location by the tile_size we get the correct tile number
...
14
votes
Simple Java MIDI player followup
Well, your post is over a year old, but hopefully this can still be of some use to you!
Javadoc
No need to say the method name again - the method name is automatically part of the Javadoc.
What are ...
12
votes
Accepted
Ping-Pong game in Java
Model vs UI
Your classes have basic separation of concerns. But as you can see by yourself some model elements like "Ball" or "Box" or "Paddle" or even "Game" ...
11
votes
Accepted
10
votes
Accepted
Simon Says: "Optimizations!"
Use interfaces when possible
ArrayList<Score> scores = new ArrayList<Score>();
ArrayList<Score> sessionScores = new ArrayList<Score>();
...
10
votes
Learning by translating - Follow the Rubberduck - Part 2: Beta
public static final String RUBBERDUCK_PATH = "RetailCoder.VBE/UI";
This value shouldn't be compiled into the binary. It should be a configurable setting that's ...
10
votes
Accepted
Medical diagnosis selector
Layout
Don't hard-code dimensions and positions. On a Mac, everything looks wrong. (I don't have your images, so I'm going to ignore them for the rest of this review.)
Furthermore, the user of the ...
10
votes
Accepted
Bare bones painter app in Java
A few notes:
Is there a reason you aren't using JavaFX? See this answer as
to why you should be using it.
Since I mostly rewrote your code, I'll do the best I can to explain all the components of ...
9
votes
Ping-Pong game in Java
Thanks for sharing this.
Looks quite reasonable to me. I have only a few thing I'd change:
unnecessary inheritance
Your Game class extends ...
8
votes
Accepted
Java Snake game
Welcome to Code Review! There's lots that can be improved about this code, so lets get started.
Use the Random class instead of Math.random()
Instead of this
...
8
votes
Accepted
Java Langton's Ant simulation
Bugs
Your simulation is buggy — and not just because an ant is involved!
It looks like you intend for each call of AntFrame.SimulationThread.run() to execute one ...
7
votes
Simple Hangman game in Java
Just quickly, here's some feedback:
I think your set up code is fine (where you're creating the JFrames etc), it's very boiler platey, but that's java.
But you shouldn't put that logic in the ...
7
votes
Accepted
Civilization Wars Game
MVC
The MVC pattern is described like this: The controller knows the model and the view. The view knows the model. About how components communication with each other: I've seen different opinions on ...
7
votes
Detecting Tiles in Java
Instead of implementing MouseListener, you can use the MouseAdapter class to implement only the method you need.
...
7
votes
Accepted
Cookie Clicker in Java
Thanks for sharing your code.
It is a really good for the first attempt.
Nevertheless there is something to mention...
Naming
Finding good names is the hardest part in programming. So always take ...
7
votes
Accepted
Java program to disturb user and waste SSD lifetime
Your program is very inefficient.
First, to use up the SSD write cycles, you should write lots of data. A single three-bytes string is not that much. Plus, there might be SSD implementations that ...
7
votes
Game of life GUI simulation using java.swing
The first thing that I notice when looking at the code is something that directly stings in my eyes: Formatting. The code is is not formatted according to the SUN or Google Code Conventions (which are ...
6
votes
Accepted
Learning by translating - Follow the Rubberduck - Part 2: Beta
Main
What is the purpose of:
private Main() {
}
I can currently think of two possibilities:
To prevent inheritance: Easily fixed with the ...
6
votes
Java Swing Text Editor
Violating important threading practices
test2 a = new test2();
The swing documentation state all swing actions should be done from the event dispatch thread. If ...
6
votes
Simple Hangman game in Java
TestLetter should accept a char instead of a String
void testLetter(String a) {
You really want to test if a single character is inside the search word, than a ...
6
votes
Bare bones painter app in Java
this.imageGraphics.setColor(Color.WHITE);
this.imageGraphics.fillRect(0, 0, width, height);
this.imageGraphics.setColor(Color.BLACK);
This part of ...
6
votes
Accepted
SpaceWar game in java
Well, then let's tear this apart piece by piece.
We will start with your questions:
One of them is "access can be package-private". I know what it means, it tries to "narrow down" the access. So, ...
6
votes
Velocity, Distance and Time Calculator
The first problem that stands out with your code is the formatting. You can always paste your code into a Java code formatter/beautifier such as that found on TutorialsPoint to indent and format the ...
6
votes
Accepted
Chess application with GUI and AI in Java
On first glance, I wouldn't call things just View, Controller, and Observable, even if they ...
5
votes
Accepted
Using actionPerformed() to call different methods per radio button selection
Indeed, the conditional branching in actionPerformed(ActionEvent) is quite complex and prone to bugs. This implementation does too many things at the same time: ...
5
votes
Accepted
Swing UI for database-to-Excel tool
Minimize failure scopes
Try-Blocks should be as small as reasonably possible. Some people even advocate extracting error-handling into a separate method of the form:
...
5
votes
Basic TicTacToe game in java
There's lots of duplication here. Cleaning that up will leave things a lot shorter.
...
5
votes
Accepted
Swing GUI in Java
Yes, that is proper use of composition over inheritance. Although some may say this is actually aggregation, due to the nature of Swing.
Composotion is the act of one object owning another object. ...
5
votes
Accepted
Integer sum program
Avoid relying on display for business logic
if (event.getActionCommand().equals("Add")) {
Be careful with this kind of thing. If you write a real ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
swing × 416java × 412
beginner × 66
gui × 54
game × 51
mvc × 37
object-oriented × 33
calculator × 32
performance × 24
awt × 21
event-handling × 16
tic-tac-toe × 15
multithreading × 13
homework × 10
graphics × 10
timer × 9
user-interface × 9
algorithm × 8
animation × 8
game-of-life × 8
design-patterns × 7
datetime × 7
file-system × 7
number-guessing-game × 7
sql × 6