226 Posted Topics

Member Avatar for techxaidz

All of the methods in the code you posted are instance methods. The only kind of method that isn't an instance method is a static method and you can recognize that by the `static` keyword. In other words "instance method" just means ordinary method, so you don't need to worry …

Member Avatar for stultuske
0
530
Member Avatar for wtosh

I don't know exactly why it doesn't work, but I can see some things which you are doing wrong. Your `clipper`s instance variables are being used like global variables to the algorithm instead of using them in a proper object-oriented way, and that just makes your algorithm hard to understand …

Member Avatar for Taywin
0
628
Member Avatar for ambageo

I see what you are trying to do. You are trying to access the static members of `java.awt.Color` such as `Color.red` or `Color.blue` except that you are trying to do it with a String that contains the words `"red"` or `"blue"`. You cannot use the dot notation that way, and …

Member Avatar for ambageo
0
204
Member Avatar for doomsday1216

You can only put `try`-`catch` blocks inside a method body. It is meaningless when placed directly inside a class definition and so the compiler is getting confused and giving you the wrong sort of error message. You probably want most of that stuff to be inside a `public static void …

Member Avatar for stultuske
0
126
Member Avatar for chira.laura.9

They have certainly chosen a hard way to make a sokoban game by using sprites to draw the grid instead of just laying it all out in an array. It's also awful how they setup `LEFT_COLLISION`, `RIGHT_COLLISION`, etc. as constants representing all four directions but then fail to use them …

Member Avatar for bguild
0
172
Member Avatar for wschamps42

A boolean is true or false, not text, so there's really no hope for doing a comparison like `answer == true` or `answer == false`; since `answer` is a bit of text it will never be `true` or `false`. What you want is more like `answer == "yes"` because both …

Member Avatar for bguild
0
120
Member Avatar for free-to-surf

I don't know how far you would want to go with it, but if you must add new features to an enrollment system, then I would try to turn it into a fully featured web service that lets people see their classes, their grades, and send messages to other students …

Member Avatar for free-to-surf
0
1K
Member Avatar for mumaga

Exceptions are best used when something happens outside of the normal flow of your program. Without exceptions you would need to handle every possible situation that might occur when you write an algorithm, and then 90% of your algorithm would be devoted to handling events that happen 1% of the …

Member Avatar for mumaga
0
171
Member Avatar for engy.adel90

The first thing your function does is call itself. That seems like it would go on forever and accomplish nothing unless there is something I'm missing.

Member Avatar for Ketsuekiame
0
143
Member Avatar for JamesCherrill

I've never been able to find a really good guide on the subject of drag and drop, but in my experience it all tends to come together pretty painlessly if you just start by making your Transferable, then a TransferHandler for each of your components that needs one. After that, …

Member Avatar for JamesCherrill
2
1K
Member Avatar for Fedhell

> I believe that the issue stems from the fact that i close the socket after each received packet, and create a brand new one. Surely you must be right about that. I can't imagine a good reason for closing the socket after each packet. You're practically asking to lose …

Member Avatar for Fedhell
0
1K
Member Avatar for godzab

for(int i = 1; i < arr.length - 1; i++){ for(int j = i + 1 ; i < arr.length-1; j++){ You are testing `i < arr.length - 1` in the inner loop when you probably want to be testing `j < arr.length - 1`. Except that you probably want …

Member Avatar for jalpesh_007
0
91
Member Avatar for mumaga

Exceptions which are not RuntimeExceptions must be handled explicitly. They cannot be ignored. A method where an Exception may occur can either declare it to be thrown, or catch it. You catch an exception by using something like: try { methodThatMightThrowExceptionA(); } catch(ExceptionA e) { whatIWantToDoIfExceptionAHappens(); } You know that …

Member Avatar for Taywin
0
11K
Member Avatar for 03hasnam

You can call `comboEmployer.addItem` at any time as long as you are in the event dispatch thread, and I'm sure you are in the event dispatch thread in your `SaveEmpButtonActionPerformed` method. So feel free to add employers immediately or at any time you feel the need, and you can always …

Member Avatar for DavidKroukamp
0
677
Member Avatar for nigelturk

In Java ints are represented using 32 bits, so 15 is represented as `0000 0000 0000 0000 0000 0000 0000 1111`, and the complement of that is `1111 1111 1111 1111 1111 1111 1111 0000`

Member Avatar for Taywin
0
4K
Member Avatar for Blink383

Your error message is saying you are trying to convert "Calculate Discount" into an number and that's exactly what you are doing, 3 times. p = ae.getActionCommand(); pf = Double.parseDouble(p); d = ae.getActionCommand(); df = Double.parseDouble(d); s = ae.getActionCommand(); sf = Double.parseDouble(s); You are calling `ae.getActionCommand()` three times as if …

Member Avatar for Blink383
0
470
Member Avatar for chira.laura.9

Of course what you really want is a 2D array to store the current state of the game, an `x` and `y` variable to store the current location of your little warehouse manager guy, a list of (x,y) target points for the boxes, a javax.swing.JPanel to draw everything, and a …

Member Avatar for bguild
0
5K
Member Avatar for Pobunjenik

I may be mistaken, but it looks like you are going left-to-right top-to-bottom updating each cell as you go. That's not how the game of life works. You are supposed to update all the cells at once. If you have two cells next to each other, call them A and …

Member Avatar for Pobunjenik
0
343
Member Avatar for Doogledude123

You haven't supplied enough information to make it possible for anyone to know. Whatever the problem is, it is not in the code you have shown us. Normally these sorts of problems can only be solved by spotting the problem in code that is supplied. The only other chance is …

Member Avatar for Doogledude123
0
1K
Member Avatar for Carpetfizz

You can't really pass variables to methods or return variables. You can only pass and return the value of a variable. So `answer` isn't really returned, only the number it contains is returned. You need to use `addobj.add(fnum, snum)` as an expression to get the returned number, such as `System.out.println(addobj.add(fnum, …

Member Avatar for Carpetfizz
0
175
Member Avatar for IcyFire

When you call `graphics2D.drawLine(oldX, oldY, currentX, currentY)` you will also want to add that to a list that records each line that is drawn, something like `history.add(new Line(oldX, oldY, currentX, currentY, graphics2D.getColor())`. Then when you want to send the image, you can just send the `history` list using a DataOutputStream. …

Member Avatar for IcyFire
0
305
Member Avatar for reuel3

s.read(b, offset, readAmount); offset += readAmount; `readAmount` is the maximum amount to read, not the amount that is actually read. The return value of `s.read(b, offset, readAmount)` is the amount actually read. You should also be checking for a return value of -1 which indicates the end of the stream. …

Member Avatar for bguild
-1
246
Member Avatar for utkarshsahu

if(pos[j].equals(d[i][j])) The value of `j` determines which of `a1`, `a2`, or `a3` you get when `i==0`. And `j` also determines which line of the input file you are on. It seems like you don't really want to use it for both purposes, so it is probably accidental. Notice especially that …

Member Avatar for JamesCherrill
0
377
Member Avatar for bguild

I have been struggling with the principles of creating a client-server design where the server maintains a data structure that multiple clients can view and manipulate with various restrictions on which client can access which parts of the structure. I don't know what to properly call a system like that, …

Member Avatar for bguild
1
1K
Member Avatar for Chuckleluck

You need to do some algebra. The algrebra is not very easy and I haven't worked it all out just now, but I can tell you the sort of thing you could to do to figure this problem out. First, you can forget about using the intersects() method. That's only …

Member Avatar for bguild
0
358
Member Avatar for bguild

I want to create a word processor. It seems like a useful project because I have strong feelings about how modern big word processors like MS Word and Open Office don't do things right, so my solution is to make one with more modest features but with the huge advantage …

Member Avatar for mike_2000_17
0
1K

The End.