masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, you've declared name and color to be static. What does static mean?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Then just stick with the first line.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Write it to another file, delete the old and rename the new to the old.

In this "special" circumstance you actually could overwrite the five characters
[pre]"#how"[/pre] with [pre]"how "[/pre] (note the extra space) using RandomAccessFile, but that is not, of course, the same as "deleting" the "#".

File are simply sequential bytes on the disk. The only way to "delete" a character from that is to shift all the bytes behind it forward, and the only way to do that is to read and rewrite them. Since you are talking about a single character, and not a block of at least 4k, all of those read and write calls to the disk would be extremely ineffecient. It is simply easier, and much more effecient, and the standard, accepted practice to simply read it and write a new file and replace the old with the new. When the files are guaranteed to be small, you can always read them in completely, modify that in memory, and then write out to the same filename (note, that, technically, this still creates a new file, though, simply overwriting the old filesystem reference directly).

Just so you know, even all of these mainstream file editors do this. They do not, because they can not (effeciently), "modify" the file "in place".

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because the compiler doesn't care that it is "the highest upper bound in Java". It sees only that is has a "restriction" now and that before, it didn't. Also, you do know that interfaces do not extend Object, right? So, if you try to add something where you are only using an interface defined reference type, then you may not be able to add it to that list (I haven't tried but seeing as how all Generics are handled by the compiler using simple reference types I believe that to be true).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You are not sure what is? Your not sure what that does, at all? or your not sure why it doesn't do what it is suppossed to?

Or is it that it "doesn't work" because you still have

private void tempTextFieldActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:
}

in your code?

This "(5 / 9)" is integer math and so will return "1". Is that what you want? No. You need to use at least one double in that part, either "5.0" or "9.0" (or both).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because Component is an awt element not a swing element. Cast to JComponent.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Then why do you need an int? Why not just

if (Color.WHITE.equals(c)) ...
masijade 1,351 Industrious Poster Team Colleague Featured Poster

BTW, objects toString method prints the hashCode of the object in hex representation. That is not, necessarily, a memory address in the first place.

So, in short, you can't access the "memory location". The physical memory location has, for the Java programmer, no relevance. You do not need it, and should not even attempt to get it.

IOW why do you think you need it? There is probably a much better, and easier, way to do whatever it is you want to do.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, you need to study threading, in general, much more, before continuing here as this stuff is so far off-track that I can't even decipher what it was you were attempting.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

First of all "run" should not be synchronized. And, if you synch on "lock", you should also "wait" on "lock", not "this". See the tutorials (and API docs).

http://download.oracle.com/javase/6/docs/

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You do

writer.write(string);
writer.newLine();

line for line.
Is that how you did it? Somehow, I don't think so.

If you insist on "caching" the output in a String and writing it all at once rather than simply writing it as you read it, then at least use

System.getProperty("line.separator")

rather than hard-coding a platform dependent line-ending.

Edit: BTW, your "memory allocation problem" is solved if you write as you read. There is no need to cache the info. The API docs.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

could you post the stacktrace

There isn't one. That is a compiler message.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

To learn JAVA roseindia.com is also a very good site

No its not. That thing is such a collection of out of date examples and hacks and bad programming practices (it actively advocates scriptlets in JSP which has been discouraged by Sun, and all but deprecated, for 10 years or more now, as just one small example) that its just not even funny.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Uhm, where, exactly.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And your problem is?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What do you mean "use it as an int". If you want the 0-255 individual values for the red, green, and blue, then maybe you should be using the getRed(), etc methods, rather than the getRGB method.

P.S. The API docs can be really helpful. Use them.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

After calling setIcon, call validate and/or repaint on the component (or, even better, on the container that contains the component).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And that is the wrong thing to do. What is wrong with the newLine method of BufferedWriter (which is what you're using)? I told you to look at the API docs for a reason. Why didn't you? You need to not only learn how to use the API docs (and tutorials, etc), but to also actually use them.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because readLine hacks off the newline (as the API docs state). See the API docs for BufferedWriter for a solution. And, reading the file twice is still extremely ineffecient. Also, the solution with the switch doesn't need if statements, at all, and you read the file only once.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

IOW "do my (home)work for me". No.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Then, as I said, the query is not returning anything since the parameter is not getting returned. That the parameter is not getting valued can only depend on what that value should be. If it contains anything other than normal letters and numbers, make sure to url encode it before adding it to the url, and make sure there is a value. In any case, this is now more a JavaScript question than it is a Java question. Moving this thread.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What do you think the 2,3,4 and 10,11,12 are? Especially when combined with the description from the first post? And why do you still have a for loop there? Where is there a for loop shown in the pseudocode? IOW, those "do something" blocks need only be the buffer.append stuff (and a break, of course) and all that other bs you can get rid of.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Lets see your implementation of that while/switch.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Just simply do a

//pseudo code
while(readline)
  switch(++count)
    case 2:
    case 3:
    case 4:
        do something and break
    case 10:
    case 11:
    case 12:
        do something break
    default:
masijade 1,351 Industrious Poster Team Colleague Featured Poster

What is this suppossed to be?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Why don't you try printing out what's returned? Also, where is the catch block? You're not just ignoring exceptions, are you?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Make one up and then use the ftype and assoc commands to create the associations (on windows, on Linux you probably need to use the "control panel"). Google those commands.

Edit: And, if you wish to "deploy" that association, then make sure whatever "installer" maker you have can handle the registry changes (on windows and the equivalent on *nix).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay? And?

The response still needs to be a properly formed html (actually, since your doing xmlhttp probably xml) response and not just a bare word.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
ftype jarfile="C:\Program Files\Java\jre1.5.0_22\bin\javaw.exe" -jar "%1" %*
assoc .jar=jarfile
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yes, it is suppossed to be java but with the -jar option. Take a closer look at that association. What is the complete command? If it is not the one provided above, then change it to that.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You can't have a Frame within a Frame. You can have a JInternalFrame within a JFrame, but not another JFrame. Why do want a JFrame inside of a JFrame? If it's because you want to reuse a class that currently extends JFrame, then, well, now you see one of the problems with extending top-level window classes. Rewrite it to extend JPanel (and it's main method can still create a JFrame to put itself inside of so it can still be used stand-alone, which is how it should be done).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Looks like your file associations are incorrect. jar should be associated with "java -jar <file>"

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Then it looks as though the query isn't returning anything, or, if that is the complete output, then the browser doesn't recognise it as a proper response.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay? And? What's stopping you? Before you answer though, make sure you do it in a new thread that you start.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Your entitled to your opinion, but how is anyone not wasting their time giving advice that's already been given, especially when all the OP need do is to include a link to the other question in order to provide a way for people to avoid wasting their time?

Edit: P.S. if you are going to say that the OP would be wasting his time providing those links, all I can say is three things

1. Common courtesy (which is what providing that link and updates is) is not wasting one's time.
2. Well, they are asking the question which at least implies that the effort should be on their part.
3. Even if it were wasting the OPs time, better that one person waste a bit of time than all others answering the question wasting theirs.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Setting a "watch" is a function of the Debugger the IDE uses, so read the IDEs documentation.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Also posted here with many of the same answers as here. I, for one, do not like wasting my time repeating advice thats already been given simply because the OP is not considerate enough to notify people that he has already asked this somewhere else.

Akill10 commented: Agreed. +1
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Use the setCharacterStream method of PreparedStatement and feed a Reader directly to the PreparedStatement.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

With an int variable and the ++ operator after every call to next()?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Actually i thought that daniweb and java forums r 2 different forums. so i posted my query in both so that i can get reply in any of these two. and i know the decency. pls dont teach me.

They are two different forums, but how does that change things? It might make it harder for anyone to know that they have wasted their time, but they will still have wasted it. So maybe you don't "know the decency" and I do need to teach you.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

FYI Also posted here.

@OP If you are going to cross-post, please at least have the decency to say that and post the links to all in all of the threads, as well as providing summarys of what has happened from time to time. No one likes to waste their time making suggestions others have already made. You should be wasting yours keeping everybody else abreast of what you've already been advised. It's only common decency.

Now, add links to any other cross-post you may have, please.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

See the API docs for the String class and its split method.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Use ";" instead of "/" as the sed separators.
instead of

s/<UDN></UDN>/<UDN>uuid:b346ee95-93b3-4922-a132-cf72762b9318</UDN>/g

use

s;<UDN></UDN>;<UDN>uuid:b346ee95-93b3-4922-a132-cf72762b9318</UDN>;g

as that "/" in "</UDN>" is garbling your sed command.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Uhm, that's described in the assignment text.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

When you execute a select query the first call to next() will "fetch" a specific number of records into a "cache" and then use that cache until the next next() call goes beyond it and fetches the next "set" of rows. The slower the network connection the more it behooves to increase this fetch size (depending on available memory). Default wise it is, for most DBs, 500, which should be enough, but you can play with it. See the API docs (for either ResultSet or Statement or maybe, even, Connection, I forget). Also, I would simply display a "wait" message while the initialisation occurs and then show the GUI after everything has been initialised. There is not much you can do about the network. If you feel you must use a "copy" I would suggest a MySQL DB on the local side as well and set it up as a replication DB.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Does it work?

Does it meet the requirements as listed?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

It probably didn't "seem" slow, it probably was slow. Properly handling DB connections and network traffic is a part of writing an application and simply circumventing those by building in a manual copy step to have the data local is a crutch and not a solution.

You should be opening the connection (or a pool of connections) on startup of the app and use it through out and there will be no problem (as long as you are using a decent fetch size).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I assume by

I got this program that supposed to display a diamond

you mean you copied some code out of the Internet for your assignment. Well, a homework assignment is for you to do, not copy. How do you expect to learn anything when you don't do anything.

If that's not the the case, apologies (and don't bother wasting your time professing that it isn't), but then you should probably choose some better wording next time.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

With what? You haven't stated what the problem is. You've stated the goal, but that is for you to implement.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

See the API docs for the Integer class.