stephen84s 550 Nearly a Posting Virtuoso Featured Poster

You are facing that problem simply because if we look inside your constructor, the "button", that you have added to your JFrame is this this one :-

JButton button = new JButton ("Click ME!!");

And you are adding the ActionListener on that button

Because of that the JButton object "button" declared at the class level is hidden in your constructor (to access it you would have had to use the "this" pointer).
And also in your actionPerformed() method when you are checking for the source of event, you are comparing it with the "button" object declared at the class level, (since it cannot see the "button" object declared in your constructor).


So whenever you are clicking your "button", the check e.getSource() == button fails, and whatever code inside the "if" block is never executed.

Please also remember to wrap your code inside [code=java] and [/code], It maintains indentations and provides syntax highlighting.

edit: I'm looking into this a little more, but I tried it with '==' and it does work, because of how getSource works. I'll run your code and get back to you.

Yes the "==" operator would work correctly here since e.getSource() would return you the reference of the original obect from where the event originated.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

How can i convert float or double to binary?

Same way I convert.

I would not mind giving you the answer, but let us see what have you tried. We only give answers to those who have at least made an effort to find them,
So first show us your code then we will help you.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

newly wrote data until i compile again

Please get your basic concepts on Java clear, compiling only takes your source code .java file(s) and generates the corresponding .class files for every class. It has nothing to do with anything that might go right or wrong at runtime

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well if the problem is solved it would be nice if you could mark this thread as solved too.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Here is your problem, line 28 of FWT2_PO

double[][] x=wc;

You cannot copy arrays like that in Java. "x" would still refer to the original array.
Use something like this to copy your array wc to x:-

int[] copy = (int[])aArray.clone();

<EDIT>
:P Again javaAddict beat me to it.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The IWT2_PO.transform method does not change anything to the first input argument. The first input argument to this function is immediately copied to a new variable. Also, shouldn't the input variable have a different scope anyway?

Incorrect, you are passing an Array, so it will be passed by reference and not passed by value, so any modifications done in that function to it would be reflected here.

Try out this piece of code, you will make out the concept:-

class ArrayTester {

  public static void modify(int a[]) {
    a[0]=99;
  }
  public static void main(String[] args) {
    int beta[] = new int[10];
    beta[0]=1;
    System.out.println("beta[0] = " + beta[0]);
    modify(beta);
    System.out.println("beta[0] = " + beta[0]);
  }
}

It will output :-

stephen@steve:~/Development/java/daniweb> java ArrayTester
beta[0] = 1
beta[0] = 99

<EDIT>

I guess JavaAddict beat to the next post.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Since you have not posted the code of the two functions I can only guess that the transform function mentioned in the commented line here :-

recovered=IWT2_PO.transform(denoised, 4, QMF);

is performing some modification(although it appears that it should not do so) in the value of the denoised array, (whose contents you are printing). Theres nothing strange in that, its normal.
Also reframe your way of asking questions, by the title of the thread strange java behaviour? , and also the way you posted, it appears as though you have claimed to have found a bug in the JDK, but it is the very basic concept of passing variables to functions (pass by value and pass by reference) which is at work here.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Please post your code in tags, its almost impossible to read without them.

Already had given her this advice in the first clone of this thread, but she just rather chose to just ignore it and created this one

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Try this link.
And if you still cannot figure it out then let us know.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

@clueless101
Why did you put what you are saying inside [QUOTE] tags. Any specific reason for it ?
I remember you doing that in some other thread too.

Also just like javaAddict, recommend you read the Javadocs more often in fact whenever you are planning to use a certain class from the java library, it always advisable to go through its Javadocs and the Javadocs of the classes related to it, that way not only will you be able to clear your concepts about the classes you are planning to use, but you might actually discover a lot more valuable information along the way which could be useful in your future adventures with Java.

The following is the link to the core Java SE 6 docs:-

http://java.sun.com/javase/6/docs/api/

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Take a look at the Runtime class. Although I have not tried it with parameters, I think all you have to do is give the entire command to execute to its exec() method and it will return you a reference to that Process.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

My advice would be to confirm that really the file cannot be found. Take a look at the javadocs of File class. It has an "exists()" method using which you can really confirm whether the file can be read by your Java program or not.
If the "exists()" method returns false thens its confirmed that your code cannot reach the XML file but if ii returns true then I guess you have to check your XML file.
Now in case it returns false, you could try moving the xml file inside the folder which holds the your Eclipse Project (not the workspace, project folder is inside the workspace) and use just the relative path (i.e "blank.xml" if it is placed directly inside the project folder).

Also keep in mind the case of the filename in Java. Although I cannot confirm it since I am mostly on Linux, *I think* Java is case sensitive about file / folder names even though Windows is not, so also try renaming your file to all lower case and do the same while accessing it from your program to see if it works.

Hope it helps.

Tyster commented: Many Thanks for your help! +2
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

thanks very much m8 i will try this 2moro hope i can get it 2 work thanks

Too much of an effort to type in the full words ???
Let me just quote some of the member rules here:-

We strive to be a community geared towards the professional. We strongly encourage all posts to be in full-sentence English. Please do not use "leet" speak or "chatroom" speak.

Besides being against the rules here and plain annoying, the opposite person can spend more time solving your problem rather that trying to understand what you are actually saying.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Thank you for your suggestion. Can you direct to me to a good source where I find out how to use this expression? I'd like to finish this and move on to another project involving a JSlider.

Again, thanks for taking the time!

What he has used are called Regular Expressions and in my very first post, if you had cared to see properly, would have found the tutorial for them. But then here it is again:-

http://java.sun.com/docs/books/tutorial/essential/regex/

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

To quote the Javadocs this is how substring(int,int) works :-

Returns a new string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1. Thus the length of the substring is endIndex-beginIndex

So this:

begin.substring(1, begin.length() - 1)

Would always skip the last character of your string.

Use this instead :-

begin.substring(1)

Since you want the entire substring till the end.

You need to go through the Java docs of the String class first so that you know how to use these functions. You can check that out here.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The split() function of the String class accepts a Regular Expression as an argument, You seem to be under the impression that it accepts comma separated characters which is incorrect.
If you want to check more about Regular Expressions in Java, this is the best place.
Also note the double back slashes (\\) mentioned by legilimen, the first back slash tell the Java compiler that the following "\" is not an escape sequence ( like "\n" is used to indicate a new line). So in effect when the regex parser encounters it the expression is reduced to "\.?!", this "\" indicates to the regex parser that the following "." is not a regex quantifier.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Also another suggestion as far as using StringTokenizer is considered, to quote the javadocs :-

StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split method of String or the java.util.regex package instead.

So always make it a habit to go through the Javadocs if you are using Any class for the first time.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

It's quite annoying to edicts like those going on in here. I use Mapbasic as a basic GIS tool. There is no GUI developer and it's a pain in the arse. I genuinely believe that developers who make suggestions like 'oh you know nothing if you use a GUI designer' are just people in ivory towers; I don't know how you operate, but I have time frames to adhere to and if there's a tool that does something quicker for me, rather than doing it long hand, then it gets adopted and adopted quickly. My advice would be to find an IDE that you find intuitive (we all find them different by the way) and just get used to using it.

I guess the Luddites were quick to slam machines working for the owners as they weren't being properly hand crafted. Ad hominem attacks are spiteful and there's no place for them.

I emply a front end graphics person for my web sites. She uses Dreamweaver and the work she produces no developer could. Find an IDE you find ok to use and learn about it. Or just use what makes your life easier mate.

Well phallett, in school while learning the English language we were taught one very important thing "Reference to Context".

I suggest you refresh some of that, Peter over here is obviously speaking in context to a beginner, who is just starting out with Java and hence advising him to avoid using GUI designers directly …

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well I guess your actual problem has been solved by stultuske, But still I would like to mention a few things by looking at your code :-

Firstly Java is an object oriented language and its true power is manifested in that only, but you have basically pulled it down to the level of a Structured Programming Language.

Secondly instead of those big line of "if" statements have you ever considered using "switch case", It would solve the problem which stultuske is mentioning about, if you need help in that too then just go here.

And finally I also remember you had asked for a better IDE for Java as compared to BlueJ. Honestly judging from your code here, you are just starting out with Java so stick with either BlueJ or JCreator Lite do not try to start using Netbeans or Eclipse, you will simply be lost there.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Actually I never got exposed to IntelliJ IDEA cause of the fee for the license, ever since my college days when I got exposed to Java, I had to stick to the free one available, cause my college (and now my work place) would never agree on spending cash on any development tools (and I dislike using pirated software) also I can use the same IDE at home. So I have learned to stick with the free alternatives.

And I also agree JCreator Lite was my first real Java IDE and is the recommended way to go for beginners.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Honestly the two big names that come to my mind are :-

  1. Eclipse
  2. Netbeans

Personally I prefer Eclipse, but NetBeans is a pretty good IDE too. But I would not recommend either if you are just near the beginner level, but if you are feeling too tied down in BlueJ may be its time to give either of the two a try.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Now let us consider your traingle has three vertices
A (x1, y1)
B (x2, y2)
C (x3, y3).

Now if you want to calculate the distance between any two points ex P(x1,y1) and Q (x2, y2) on a plane the formula is:-
Square_Root [(x2-x1)^2 + (y2-y1)^2]

So using that formula you can get the length of all the three sides of the triangle. Next to calculate the Area of the triangle Whose length of sides are a,b and c the formula is :-

Area = Square_Root [s(s-a)(s-b)(s-c)]
where s -> Semiperimeter that is half the perimeter.

I think this is called the Herons Formula or something similar.

Now I have given you the formulae just convert them to your code.

Plus are you sure the code you have pasted is the working code ?? Cause the area of a rectangle is (base (areax) * height(areay)) why do you have "(area * area)" added to it ??? Are you sure about what you are doing here ??
Also your program would fail if the rectangle is not perfectly horizontal that is the base is inclined at some angle with the X-Axis.

I hope this is good enough to get you on the way.

<Edit> I think you code is currently working cause since the variable area is declared at the class level, it is by default initialized to 0, hence (area * area) would give you just …

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Its refreshing to see that some posters pay attention to atleast some of the rules before posting, but we wont give you ready made code, but we'll help you write it yourself.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Add some functionality, Compile it and run it and see if it behaves as you want.
Why do want our stamp of approval on it, its not like the world would come to an end if you get a compile error or a wrong output while trying out different combinations for a solution, you might end up discovering a lot more of the Java language that way.

BTW yes that is correct.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Following is another site which gives you javadocs with examples.

http://www.kickjava.com

>>Performance<<
Programming in Java over the years, I have encountered quite a few myths (ex. making your variables and methods final), although the following article by Brian Goetz is nearly three years old, I still encounter these "myths" about Java quite a few times mostly from newbie programmers and sometimes even experienced developers.
http://www-128.ibm.com/developerworks/java/library/j-jtp09275.html?ca=dgr-jw22JavaUrbanLegends

Then theres the question of performance of Java both speed and memory management.
The following article again from Brian Goetz should put to rest anyone's doubts in the performance of Java in those sections:-
http://www-128.ibm.com/developerworks/java/library/j-jtp09275.html?ca=dgr-jw22JavaUrbanLegends

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Now consider your code:-

if (nummer[i] < 0 && nummer[i] > 9){

Now according to me since this is a char array, you numbers will be stored as chars and hence you will need to check for their ASCII equivalent values, or better you could just use the isdigit() function, to figure out if the current character is a valid digit or not.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

@thariqrasheed

The answer had already been given to you. But your inability to figure it out is at best apathetic.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Read my first post carefully, I had said set the content type in your servlet to text/plain not text/html and do you always have to quote the previous message whenever you are replying ???

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Your <select> element (and also any other element eg textfields, checkboxes, etc ) should be inside the <form> </form> tags, if you want your data to get posted (via GET or POST) to the URL specified in the form's action parameter.
From what I see you seem to have no idea how HTML forms work, so I would suggest this tutorial.

And PLEASE use code tags, when you are pasting code. You can read about them here.
This is already your fourth post in roughly 7-8 months and the fact that you still haven't read the rules only shows your ignorance.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

<ignore>

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

This link will help you on how to configure NowSMS to read incoming messages and forward them on to an HTTP URL (which could be your servlet, JSP whatever).

I had already told you in one of your previous threads to check the reference manual of NowSMS for that, but it seems like you are just more interested in ready made answers.

In the URL (JSP / Servlet / ASP / PHP /...) that you make (and set in the "Command to Execute" field) all you have to do is set the content type to "text/plain" and whatever text you return in the response will be sent back to the user who sent the message.

Also I had already mentioned it to you that your SMS speech is irritating, this is the last post of yours I am reading if you keep it up.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

> Thread.getThread().sleep(3000); //Pause for 3 s Thread.currentThread().sleep(3000);

That would give you a warning since sleep is a static method and from what I have seen applies to the current thread only, So its got to be:- Thread.sleep(3000);

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

My name is Jennifer and i love computers. I am into programming but i struggle a bit with it. I am 22 years old, i have a nice boyfriend, i am Haitian living for the moment in the States to complete my degree. i love reading, sleeping, dancing and eating. i hope that i will meet new people. kisses

Sheesh, I guess we should dwell in the Community Introductions section more ..... :P

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Sorry Stultuske but my first post already does what you are recommending in your post.
But the following line in his second post contradicts what he says in his first post:-

i wonder if i could not have all the words of the array appearing at the same time

So here he does not want the entire content of the array to be displayed at the same time.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

but i wonder if i could not have all the words of the array appearing at the same time

What is it that you want exactly, your question is just too generic, I do not know what to make of it.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The following piece of code:-

label3.setText(arrayOfTen.get(i));

Replaces whatever previous value you have set for the label with the new one you have specified here.

Use this in case you want to also retain the previous content of the label:-

label3.setText(label3.getText() + " " + arrayOfTen.get(i));

And please use code tags when you are posting code. All you have to do is put your code inside [ code=java ] and [ /code ], its is already mentioned in the announcement at the top of the Java forum.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

well if the problem has been solved it would be appreciated if you mark this thread as solved.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

In Java null and "" are not the same thing.

null is the actual universal NULL, i. e. nothing.
On the other hand "" is a blank String object.

If an object is "null" calling any method on it would give you a NullPointerException, hence we need to first check for null and only after that we check if the String is "blank".

"null" I assume is returned when the parameter is not present at all in the request (which is not your case), but you had mentioned encountering a NullPointerException earlier, thats why I recommended both the conditions for your case.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Ok.. What was the output when you replaced

if (request.getParameter("UserName")!=null)

with the following condition:-

if ((request.getParameter("UserName")!=null) && !(request.getParameter("UserName").equals(""))) {
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

My first suggestion would be do not this task inside a JSP. JSPs are only for making your user interface, the processing i. e. your "scp" should be inside a Java class.
Second suggestion is instead of

scp /sx04a1/jakarta-tomcat-5/webapps/maltixa/index.jsp jipbekok@fff04.ff.ff.es:/sx04a1/jaka...ixa/index5.jsp [/code]

give it the absolute path of the "scp" binary on your system like this :-

/usr/bin/scp /sx04a1/jakarta-tomcat-5/webapps/maltixa/index.jsp jipbekok@fff04.ff.ff.es:/sx04a1/jaka...ixa/index5.jsp[/code]
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

eventhought.... same thing!

i am really confused!

Have you tried by changing the name of the field from "UsrName" to "UserName". Next show us your servlet code and why you feel that the code inside the "if" block is getting executed.
Note when pasting your code use for java code and [code=html] for HTML, it provides syntax highlighting.[code=java] for java code and for HTML, it provides syntax highlighting.[code=html] for HTML, it provides syntax highlighting.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

There is your problem

<input type="text" name="UsrName" maxlength="15" size="15"/>

Check the Spelling of the name given to the field, you have give "UsrName" it should be "UserName".

But it should not enter the if block as the condition ( (request.getParameter("UserName")!=null ) )still evaluates to false.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Thats strange the NullPointerException would be thrown only in case request.getParameter("UserName") returned NULL, but in your first post you had said request.getParameter("UserName") != null evaluated to true for all cases.

Try the following condition:-

if ((request.getParameter("UserName")!=null ) && (! request.getParameter("UserName").equals(""))) {

It should accommodate both conditions when you get a blank as well as when you get a null.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Can you show me the code of the page where your text field is located.
Have you set the default value for your text field to a blank string i. e. ("").
In that case the check for (!= null ) would fail even if your text field was blank. You would have to check for blank string in that case like this :-

if((! request.getParameter("UserName").equals(""))) {
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Ok... Now I am going to just assume how you wish the servlet should work, If you have an already registered user, you want to just display "You are a valid user" and if the user is invalid you want to display "Please register !!".

So lets see where you could be going wrong:-

String sql = "select mobileno,password from newuser where mobileno='"+ mobileno + "'and password='"+ password + "' " ;

Now the above query would return you a database record if and only if you got a valid user with correct mobile number and password hitting your servlet.

So instead of while(rs.next()) you should instead opt for if(rs.next()) like this :-

if (rs.next ()) {
  // If we get a record it means the (mobileno & password) 
  // combination is already valid.
  // so just close your statements and do whatever you want
  // for a valid user here.
} else {
  // No records found for user in table, so user is invalid.
  // So put the appropriate message for invalid user and
  // the registration link here
}
javaAddict commented: Nice call +3
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Tell us exactly whats going wrong and how do you want the servlet to behave ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Iam ..sorry.. really i dont know how to use [code] tags .. plz i will go through those code tags it now...from next time i will follow code tags definately... plz check that this time...

No I am not, I gave you the link in my first post, if you cant find it then see this :-
http://www.daniweb.com/forums/announcement9-3.html

Edit your post and add the code tags to it, it should not take more than a few minutes.
And PLEASE write the full words why do you eat up sentences with the "..." and the SMS language(used with Mobile handsets) when you have a complete keyboard in front of you.

And you have not even mentioned what is going wrong now, after you changed your query.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Am not looking at that post until you start using code-tags to wrap your code. I already mentioned it to you in my first post, but you just wish to keep ignoring it and please start writing your posts in English. The SMS speech and the "..."s you are using are irritating, I guess that would not be too much to ask.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

but i want to compare dynamically ..if i give particular number then it displays those results.. but if i give another number then i have to change that in servlet also...i want dynamically if mobilenumber enterd in jsp then it should be checked with db and comapres with enterd value.. if its there dispaly already existed if not register..how i should i do this?

If you would just merge my query with your code wouldn't it do the same or you need me to spoon feed you the exact java syntax, then here it is :-

String sql = "select password from newuser where mobileno=" + mobileno;
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

As far as your problem goes you need to put a "where" clause in your select query like this:-

select password 
from newuser
where mobileno='<the value that you got in your request>'

So your "while" will be entered only if the mobile no is valid (and if valid give you the password of only that "mobileno" )and you just have to check whether the "password" is valid in your "if" condition.

Also I can see that you are overwriting the value in the variables "mobileno" and "password", first you are storing in the value you get from the request here:-

String mobileno=request.getParameter("mobileno");
String password=request.getParameter("password");

And then you overwrite them if the corresponding values you get from the database here:-

while (rs.next ()){
  mobileno=rs.getString("mobileno");
  password=rs.getString("password");
}

Also another suggestion do not use user mysql "root" login to do such trivial tasks. Use root is only for when you have to perform administrative tasks on your database, for normal use create another user account.