JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Don't confuse string variables with Strings. In C terms, a String variable is a pointer, and its initial value is null. You can only create a string via new String(some parameters) or as a String literal "some string". In both cases the size of the string is known when it is created, and a suitable amount of space is allocated dynamically on the heap when the String is created.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

When you have a serializable class you're supposed to define a serialVersionUID that ideentifies the version of the serialized form - if you change how it's serialized you're supposed to change the serialVersionUID.
It's a complete waste of time and a real annoyance. Either ignore it, or create a private static final long variable called serialVersionUID and give it an arbitrary value, eg 0, then forget it.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Maybe those method definitions belong in the class they apply to, ie in Student there is a delete(Student s) method, in Course there's delete(Course c) etc etc. (These should probably be just named delete() defined as instance methods.)
In a typical controller class you will call those methods, but not define them.
If there's significant duplication between the methods in all those classes then consider inheriting them from a common superclass, or using a low-level utility class or classes that they all call on for common functions (eg database updates)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

What are you doing?
This is a duplicate of your post 2 days ago, with exactly the same code mistakes, and completely ignoring the input you got from your previous post.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

(u == user)

As gets posted here about once a week on average... don't try to compare Strings with ==, use .equals instead. Google for details.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Have you filled your Board with non-transparent components?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, you only need one array.
Yes, the numeric value of the char the decimal for it in the ascii table.
Not exactly ... Java uses 16 bit UniCode to store characters, and these are only the same as ASCII for codes up to 127. ASCII extended characters are basically irrelevant in Java as UniCode handles all such symbols far better.
Having said all that, you don't really need to know the decimal equivalents, just use chars and they will work as both letters and numeric values as if by magic, eg

for (char c = 'a'; c <= 'z'; c++) System.out.print(c);
or
array++;

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Remember Java chars are numeric - ordinary characters correspond to integer values under 128. If you have an array of 127 ints you can use a char as the index to access an element of the array and increment it...

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You are confusing Objects with variables. A variable is reference (pointer) to an Object. You can't assign null to an Object - that doesn't even make sense. You can assign null to a variable - it means that the variable stops referring to an Object and now refers to nothing.

Box yellowbox=new Box();
Box redbox=new Box();
...
redbox=yellowbox;

You create two Box objects by executing new Box() twice. Variable yellowbox refers to the first Box, and redbox refers to the second Box. But then you copy yellowbox to redbox, so now both variables refer to the same object (the first Box). You no longer have a reference to the second Box, so you can never use it in any way, and it will be garbage collected.
Some time later you assign

redbox=null;

Now redbox refers to nothing, and if you try to use it you will get a null pointer exception. The Object is not affected by that statement, and yellowbox continues to refer to it.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I guess you'll have to write a small method that splits the String into its components, retrieves the actual Objects represented by those sub-strings, then start with an empty TreePath and use pathByAddingChild(Object child) to add all those objects to build the fill path. It's only the step of retrieving the actual Objects represented by the sub-strings that could be difficult, depending on your specific application.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

total and total1 are local variables in methods sample and sample1 respectively. They do not exist outside those methods, and cannot be accessed from outside those methods.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's INSIDE a method. YOU must put the class definition OUTSIDE any method definitions.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's a class definition, not a method. It should be inside the class where you have the addActionListener calls, but NOT inside any method. Don't declare it public. You just need to close all the {} properly

class myListener implements ActionListener {
    float amount;
    public myListener (float amount) {
       this.amount = amount;
    }
    public void actionPerformed(ActionEvent e) {
       amountInserted = amountInserted + amount;
       balance = balance - amount;
       lInserted.setText("Amount Inserted: " + amountInserted);
       lDue.setText("Amount Due: " + balance);
       checkBalanceisZero(balance);
    } // closes actionPerformed
} // closes class myListener
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Looks like you inserted that code in the wrong place (OR there's an error on the immediately preceding line). That code should go inside the class, but outside any methods.
ps: Don't forget the declare float amount; in the myListener class

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

... but even better:
create class as above. Add a variable for amount, that can be set by a parameter in the constructor. When adding instances of this class to each button pass the appropriate value into the constructor.
Now there's no need for getSource or a switch or any of that stuff; just add/subtract the amount (same code for all buttons, just the amount varies)

twentyP.addActionListener(new myListener(0.20));

class myListener implements ActionListener [
   ...
   public myListener(float amount) {
     this.amount = amount;
     ...
   public void actionPerformed(ActionEvent e) {
     amountIn = amountIn + amount;

...

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

IMHO Java itself is more solid than the OS it runs on, but Java's support for serial comms is very old, and was never very solid in the first place. I did a project years ago to interface with a serial hardware control device (multiple digital I/O lines) and found that establishing communication was a 90% affair, and that it often hung up, requiring a restart, if there were any problems. To be fair, that may have just been my fault, but I don't think my code was that bad.
I would never get in a car that depended on Java serial comms to keep the engine working safely!
Personally I would build a small C DLL to handle the comms protocols and hardware interface, and call that via JNI or whatever. If you design it with that use in mind it should be pretty easy.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Don't let Apple hear you say that...

Anyway, I can't tell anything from the code snippet you posted, except that you don't have print statements to display the results of each step as you perform it. For example if you print each record immediately after reading it you can see if there's something wrong with your Scanner. If it's OK then move on to printing the results from the StringTokenizer, etc , until you see where the problem starts.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
Scanner scan= new Scanner(inputFile);
String N= scan.println(N):

I don't know how you can read anything with this code - it won't compile - there is no println method in Scanner (not to mention the missing catch)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK - if you're happy then mark this "solved" so people know whether or not to read it!

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Lines 17,18 are executed regardless of whether you have found the account to delete or not - they are outside the if test.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You can populate a JComboBox with any kind of Objects, and it will use the objects' toString() method to display the object, but when you query the selected item you will get the original object.
If you don't want to have your toString() method just returning the name, then use a ListCellRenderer on your JComboBox to format the objects the way you want

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I've already explained those errors, and pointed you towards a solution. Stop asking the question over and over again, start processing the answers.

And I don't need to compile your code because its absolutely obvious what it tries to do and what's wrong with it. One last time:
f1= new FileInputStream(args[0]);
If that call fails what do you want to do? Right now you carry on and try to read from f1 anyway. Obviously that's not going to work. Maybe you should consider exiting your program if you can't create the FileInputStream.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

e.printStackTrace()
prints complete details of any run-time error (Exception) that happens inside the try block when the program is executing.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It tries to open a file using a file name that is supplied as a parameter when the program is run.
The file name may be wrong. The file path may be wrong. You may not have read permission for the file. Any of these will make the call fail and throw an Exception.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

f1= new FileInputStream(args[0]);
If that call fails what do you want to do? Right now you carry on and try to read from f1 anyway. Obviously that's not going to work. Maybe you should consider exiting your program if you can't create the FileInputStream.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Did you read my post where I explained that error. Did you change your program like I said?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If line 14 throws an exception then you will get to line42 with f1 not initialised. Similarly for f2
ps NEVER do this:

catch(Exception e)
{
 
}

when you get any error of any kind in the try block you will see no error message of any kind, and will have no idea what happened. Display the error message in EVERY catch block, like this:

catch(Exception e)
{
   e.printStackTrace();
}
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If that is painting 1 sphere OK, then you need to put in a loop like you did for the movement, and paint each sphere one at a time in the loop. I can't say more becuase I don't have all the code, and the structure is not clear.
ps: I'm going offline now, so good luck.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

In your code to move the spheres you have (correctly)
for(int i =0;i<spheres.size();i++) //for each sphere ...

but in paintComponent you have
g.drawImage(sphere,... (one sphere only)

in paintComponent you need to paint all the spheres.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, just get stuck in! The whole update method is maybe 20 easy lines of code.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Each sphere has a position and a velocity. The update method is called at regular intervals. Every time the update method is called you update the position according to the velocity. The you check to see if you've hit the boundary, in which case you have to change the velocity to represent the new direction. So regardless of what's going on with the panel, you are maintaining the position and velocity correctly all the time.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I thought I did. "Change the code in your previous post/question to make B b static. Now you have 2 threads each calling the sum method on the same object (static b)." That's an example of one method being called by many threads at the same time on the same object

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes. The second thread cannot enter the method until the first one leaves it, no matter how long that may take.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Change the code in your previous post/question to make B b static. Now you have 2 threads each calling the sum method on the same object (static b).
If sum is synchronised then the second thread will be held up and won't be able to start executing sum until the first thread has finished executing it.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

sorry man, I'm not going to try to write a tutorial here, even if I had the time. There are loads on the web already, most of them better than I could do anyway. Like these:
http://www.java-samples.com/showtutorial.php?tutorialid=306
http://www.avajava.com/tutorials/lessons/how-do-i-use-the-wait-and-notify-methods.html
Read them carefully then, if you have specific questions, start a new thread for it.
OK?
J

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Been there before, usually. Pls mark this "solved" if you're happy.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

No, you have two instances of A, each of which creates its own instance of B, so that's two B's.


If you had
static B b = new B();
then there would only be one b.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

What output do you get; [hello1[hello2]] ?
A synchronised method like yours is synchronised on the current object (instance of the class). Because you have two different instances of B each invocation of sum is synchronised on a different object, so the synchronisation has no effect. If you synchronise them both on the same object you will get the expected output.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Here's an overview of a typical way to do this:
Create the spheres as instances of a Sphere class- each Sphere with its own size, position, velocity. Maintain a list of all the spheres you have created. In your main method start a javax.swing.Timer to call an update method on each sphere in the list every n millisecs (eg 60 mSec) - Sphere's update method updates the position and velocity appropriately. After calling all the update methods call repaint() for the panel. This ensures that the physics of moving and bouncing etc proceeds in real time.
In the panel's paintComponent method call a draw method for each sphere. Sphere's draw method just draws the sphere at its latest position. This ensures that the panel stays up to date, but doesn't interfere with the physics if there are extra or skipped repaints (eg if the window is moved or resized etc etc).

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in doing your homework for you.

DaniWeb Member Rules include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/forums/faq.php?faq=daniweb_policies
http://www.daniweb.com/forums/announcement8-2.html

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Three personal opinions:
1. An IDE is a very useful tool for someone who knows what they are doing, but for a beginner (like most posters here) it leaves most of Swing, eg layout managers, listener classes etc as a mysterious black box. Most experienced users here recommend that beginners stay with a code editor until they have gained a good understanding of the basics.
2. If you're just creating a simple fixed layout the IDE GUI generation is fine, but as soon as you want to do anything more advanced, eg dynamic creation of controls based on runtime data, you run into a complete brick wall.
3. If you are targeting cross-platform then no GUI generator I've ever used handles GridBagLayout options well, It's easier just to code it yourself.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

This is my code now , it still prints me java.awt.Color[r=255,g=72,b=72]

I already explained this - did you read my earlier post?

You create row containing a Color.RED as its value and it's displayed as "java.awt.Color[r=255,g=0,b=0]", which is exactly what you would expect since the default renderer calls toString() on the value Object.

model.addRow(new Object[]{"",new java.awt.Color(255, 72, 72)});
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Was that a question?
You create row containing a Color.RED as its value and it's displayed as "java.awt.Color[r=255,g=0,b=0]", which is exactly what you would expect since the default renderer calls toString() on the value Object.
To achieve the result you described in your first post I would expect to see some piece of code in the getTableCellRendererComponent method that tests the row number and sets the background color according to the row number.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Maybe this:
For a delimiter of one or more white space chars OR a "/"
useDelimiter("\\s+|/")

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's not the same format as the data in the first post, so onviously the answer is going to be different.
Are you saying there may also be arbitrary white space in the data? Or only inbetween numbers? As well as or instead of the / demiliters?

Assuming they are not embedded then you need to delimlit on any number of white spaces and/or / characters.
You could try useDelimiter("[\\s/]*"
... but there are others here who are for moreexpert in regexs than I am.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The only problem with that is if there are many many such lists you will have to go to all of them to remove any possible references. If that really is a problem then use the solution I mentioned - in Item have

ArrayList<List> placesWhereThisIsReferenced = new ArrayList<List>();

then whenever you add this item to a list, add the list to placesWhereThisIsReferenced
The to delete the Item everywhere

for (list list : placesWhereThisIsReferenced) {
   list.remove(this);
}
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You need to keep clear in your mind the distinction between a Java object and a Java reference. The only way to create an object is via the "new" keyword*.
The things that go in variables and ArrayLists are references top objects. If I say

Item i = new Item("Cabbage");
Item i2 = i;
myArrayListOfItems.add(i);

I still have only 1 object and 3 references to it.
You have no control over where an object is stored. The Java VM allocates storage for new objects somewhere in its memory, and keeps track of it. All you can do is create references to it.
When you say "it will need to be stored in an initial place (in an ArrayList or something), then it will also need to be stored in each section" then you are mistaken. In Java, a reference to it is stored in the initial place, and a second reference to it is stored in each section. There is still only one copy of the Item, somewhere in the JVM's memory.
It's also a mistake to think that the references duplicate anything at all. The existance of a reference in "initial place" asserts that this item is known to the store. The existence of another reference in "Entertainment" asserts that this is an entertainment item - which is new information.
Deleting references is no big deal. Deleting references to an item in two places isn't going to take any significant time unless you …

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Integer.getInteger(tempNum) returns an Integer object, but your bsnk account constructor requires an int value. Have a look at Integer.parseInt(...)
(Etc)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Line 7 is that a "" or a " " ?
When you get bugs like this try printing your working variables at key stages in the code, eg if you printed the contents of decryptArray, or even just decryptArray.length, that would confirm whether or not your split was working.

Ntropy commented: What a legend +1
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I don't know why I'm rewarding your laziness like this, but here's the code you could have / should have written for yourself in less time than it took to write that post

String input = "12/345/6789";
      Scanner s = new Scanner(input).useDelimiter("/");
      System.out.println(s.nextInt());
      System.out.println(s.nextInt());
      System.out.println(s.nextInt());