|
Well it still isn't set properly; take a look at the result of your edit.
It should be:
<pre lang="java">
// code here
</pre>
so it looks like
private boolean validateInput(String input1, String input2)
{
}
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Oh, I didn't have the code highlighted first and it showed up at the top of my code. So, I copied the </pre> and put it at the end of my code (but forgot to delete it from the top). Should be all set now for review!
|
|
|
|
|
See how much easier that is to read?
The statement at the top of your loop is:
while (!inputValidArray[0] || !inputValidArray[1])
Are you sure that should be an OR expression rather than AND ? If the first value validates OK then you set counter to 1, but then break out of the while statement because inputValidArray[0] is now true .
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
@Richard
Yes, I agree that using the formatting codes makes the code much more readable!
As far as my code goes:
Ah I understand what your saying about using the OR instead of AND, but I don't think I'm having a problem with that because each inputValidArray is negated using the exclamation. So, the loop will not be broken unless both are not false. I could have used:
while (!(inputValidArray[0] && inputValidArray[1])) instead.
I think my main issue is that I can't get the code to stop and allow the user to fix the input in jTextField1 after it determines the input is bad. I set the focus and highlight it, but the code continues on and looks at jTextField2 and does what it should. Then it comes back up and checks input one again, which is already 'bad' and basically creates a loop I have to manually break out of. Does that make sense? Thanks!
|
|
|
|
|
I misread the code and your question earlier. I think what you need to do is add some break statements to get out of the loop when one of the values is bad. This should then allow the user to correct the input and then you can call the validation method once again. Something like:
Create_Error_Message_Dialog_Box(errorMessage);
textFieldArray[counter].requestFocusInWindow();
break;
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
@Richard
You know, I thought of that and that would be the easiest way out. I was hoping there was a way to keep the loop going, but, I guess I was in denial! lol Thanks for your help!
|
|
|
|
|
I'm not sure (obviously) how the whole app fits together, but this would be the 'normal' way of doing things.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I totally agree! I let myself get hung up on not breaking the loop. Bad input should break the loop, since proper input is mandatory.
I've pretty much just started learning java on my own, but had taken a C# course last semester, so I have a little bit of a leg up on it.
For a linux class project, I'm going to make an IPV4 subnet calculator using the linux Netbeans IDE. So, I thought I'd make a simple GUI program in Netbeans to figure out the GUI mechanics.
The program this code is from is a drastically simple calculator that adds two floats (if valid) and displays the result in a third textbox.
Now, its just a matter of figuring out how to get mnemonics and keybinds to work for the Add, Clear and Exit buttons. The Netbeans IDE isn't all that clear on how to do that, so the digging for information continues
Thanks for your time on this rather simple fix!
|
|
|
|
|
LEKnowlton wrote: The Netbeans IDE isn't all that clear
Sometimes the only way to this information is to use the tutorials[^] and the API documentation[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
From what I've gleaned from searches on this:
I'm thinking that instead of strictly using the mouse click event for each button that I can use the actionevent listener and set up a case logic structure to choose which action does what.
|
|
|
|
|
Yes, that's the way to go.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Someone down voted this question for no reason that I can see, so I added a +5 in compensation.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi all, I'm a relative novice at Programming. I can't figure out if I am doing this right? I am required to correct the syntactic and semantic errors in the following program:
{
public static void main(String[] args){
int x,t;
double k;
x = 56;
k = 7;
x = 6 + k;
k = x*3.5 + 5
t = t + x;
System.out.println(x);
System.out.println(k);
System.out.println(t);
}
}
This is my attempt:
{
public static void main(String[] args){
int t;
double x,k,temp1,temp2;
x = 56;
k = 7;
temp1 = x;
x = 6+k;
temp2 = k;
k = x*3.5+5;
System.out.println(x);
System.out.println(k);
}
}
Not really sure what I'm doing, would appreciate help. Thanks in advance all.
|
|
|
|
|
Did you read #11 of the guidelines above? Your question smells of homework.
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
it is kind of - seems like one of the java certificate questions.
regards Torsten
I never finish anyth...
|
|
|
|
|
You're completely wrong - it's much simpler. You should not rewrite the code - just check out the errors.
Hint:
Take a look at the variable "t" and check the line 7 of the given code.
regards Torsten
I never finish anyth...
|
|
|
|
|
Instead of giving him a hint, why don't you direct him to Syntatic and Semantic error's explanation[^]?
Oxfords English < Official CCC Players Dictionary
Excuse me for my improper grammar and typos.
It's because English is my primary language, not my first language.
My first languages are C# and Java.
VB, ASP, JS, PHP and SQL are my second language.
Indonesian came as my third language.
My fourth language? I'm still creating it, I'll let you know when it's done!
|
|
|
|
|
because I didn't want to tell him that direct what he's about to find.
regards Torsten
I never finish anyth...
|
|
|
|
|
I'm doing about File Explorer which similar to Windows Explorer in Windows .
I don't know why Windows Explorer get "Extract here , Extract File" ... which have when install Winrar .
I want popup menu at forder to do it .
Any idea ??
sorry about my english !! .
|
|
|
|
|
write the functionality yourself. You don't need tools like winrar for this.
this is how you can do it[^]
regards Torsten
I never finish anyth...
|
|
|
|
|
I don't think that's what he's asking.
I think his question is something like: I want to display a pop-up menu which will give the user a list of actions associated with a file type. For example, if the file is a RAR file, I want to display the options associated with Winrar. Think Windows Explorer, you right-click on a file and up pops a menu telling you what you can do with that file.
I'm not sure how you do this from Java since finding the list of actions for a specific file type is OS-specific, and that is always where Java's "run anywhere" approach struggles. The Desktop API gives you some access to this, but it has a limited set of pre-defined actions available and I'm not sure how you add in other actions like zip or unzip (or even if you can).
There was a project on the go at one time called JDIC which aimed to make OS-specific desktop integration a bit easier, but I haven't heard about that for a while. It was basically a series of wrappers around native calls for the main operating systems like Windows and Linux. It might be worth a look, though, if it is still around.
|
|
|
|
|
Is this needed any more? compressed folder/files are nowadays opened by the file explorers.
Other extensions should be thrown against the OS to open/execute it - you'll get the "don't know how" dialog if the file extension is not known.
regards Torsten
I never finish anyth...
|
|
|
|
|
I think the whole zip file, Winrar thing was just an example from the OP. If I read his post correctly, he's trying to build a Windows Explorer clone, that's his main interest here. The whole issue of how to compress or uncompress files is a bit of a red herring. It's more of a general question about file types and actions.
The Java Desktop class allows you to Open, Print, Edit files with a bit more control than simply shelling out and trying to run the file. For example, you can test whether or not there is an Edit action associated with a file type as distinct from Open (think of *.cmd files on Windows: Open and Edit do different things). What it doesn't let you do is access non-standard options that other programs like Winrar may associate with specific file types like *.zip or *.rar, for example Extract Here as opposed to Extract.
The NetBeans Platform includes an API that allows you to associate arbitrary actions with file types, but it is up to you (the programmer) to create the association, it is not derived from the underlying operating system.
|
|
|
|
|
Thank you . Great answer . .
|
|
|
|
|
hi,
i want code for image processing in java
i am already working on this part with matlab just i want help som code in matlab thus i unable to post that code
|
|
|
|