hi

i had try, although didnt had much time, but i did not see any problems.

well done and nice work :cheesy:

hi server crash,

You have done a great work. I donot know if I ever had the patience to do such a wonderful program for the sake of hobby.

I have a couple of suggessions as far as the components are used.

1. I believe you are using key listener for validating the entry in the textfields, I would prefer you to use a document like the one that I have attached.

2. By adding key listener your code becomes more complicated and you are not detatching the textfield validation from your main code. Once you add the textfield like the one I have attached you can be sure of the entry in that textfield with out validating for each event.

3. You have made the <optional> become an empty string "" when the user clicks on the textfield. But what happens when he presses a tab. The <optional> message does not vanish, when the user types you validate for numeric entry (I have attached a screen shot of that happens), this is inconvienient for the user. If you are going to display the <optional> message try thinking on the lines of focus listener also.

4. The JTable looks very good. You have made the table headers rearrangable but handled the data very well. One suggession that I have for you is, you can make the cells non editable as this is only used by you for display.

I donot have more time now. I will check it and come back to you with more suggessions. All the suggessions are what I felt. I may be wrong as I donot exactly know what is your requirement.

Hope this helps.
Regards
Srinivas

Attachments key_listener.jpg 5.3 KB
import javax.swing.JTextField;
import javax.swing.text.*;
import java.awt.event.*;

public class NumericTextField extends JTextField
{

  private final int MAX_CHARS_ALLOWED;
  int cols;
  	public NumericTextField()
  	{
  	MAX_CHARS_ALLOWED=0;
  	}

	//use this constructor if you want to control the maximum number of characters
  	public NumericTextField(int cols)
  	{
    	super(cols);
    	this.cols=cols;
    	this.MAX_CHARS_ALLOWED=cols;
  	}

  	protected Document createDefaultModel()
  	{
    	return new UpperCaseDocument(MAX_CHARS_ALLOWED);
  	}

  	class UpperCaseDocument extends PlainDocument
 	{

		private UpperCaseDocument(int MAX_CHARS_ALLOWED) 
		{
      			this.MAX_CHARS_ALLOWED = MAX_CHARS_ALLOWED;
    	}

    		final int MAX_CHARS_ALLOWED;

    		public void insertString(int offs, String str, AttributeSet a) throws BadLocationException
    		{
      			if(str==null)
      			{
      				return;
      			}
      			String s=NumericTextField.this.getText();
      			if(s.length()>=cols)
      			{
	  			selectAll();
				return;
      			}
		
      		char[] upper = str.toCharArray();

      			for(int i=0;i<upper.length;i++)
      			{
					//this will make sure that the entered characters are only numeric.
					//you can indicate the <optional> message by giving a * or any other symbol
					if((upper[i]>='0'&&upper[i]<='9'))
					{
		  				upper[i]=Character.toUpperCase(upper[i]);
					}
					else
					{
		  				return;
					}
      			}
			super.insertString(offs, new String(upper), a);
 	 	}
	}
}

That is EXCELLENT! I didn't expect to get so much help! Right now I don't have much time, but as soon as I get time, I'll be changing the textfields. That's one thing I really didn't like about it. I tried to error proof it as much as I could, but that just complicated it even more. If you have any more suggestios, PLEASE post them.

Thanks, I really appreciate the time you just took.

I teach an Intro to Java course at a University, and often assign a mortgage applet once we learn how to do text fields, etc. Thats by far the best mortgage applet I've ever seen. Even on Bank websites!!

Very good.

Jeff

I teach an Intro to Java course at a University, and often assign a mortgage applet once we learn how to do text fields, etc. Thats by far the best mortgage applet I've ever seen. Even on Bank websites!!

Very good.

Jeff

Thanks! I really appreciate the kind reply. It's good to know it's better than most you've seen! My goal was to make the best mortgage calculator on the internet, but I think there are a few that beat me, or at least come close.

Hi everyone,

Simplllly excellent. I have seen your other software as well and i can say that they are really well thought out and executed perfectly. My favourite is the polynomial plotter. After seeing your programs i think you have an extremely bright future in the software industry.

Best wishes for your future endevours

Richard West

Oh, the polynomial plotter if my favorite. That project there reallly got me hooked on using sliders. You'll have to check back when I get it done in applet form so you can check it out yourself...Thanks for the compliments by the way.

This article has been dead for over six months. Start a new discussion instead.