aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JTextField problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextField problems" Watch "JTextField problems" New topic
Author

JTextField problems

Alex Rugav
Greenhorn

Joined: May 03, 2006
Posts: 19
how do you set the size of a jTextField so that it does keep on accepting input e.g name and password textfields

how do you also make the JTextfield accept text only denying numbers and alphanumeric e.g for a name JTextField.
Li Richriver
Greenhorn

Joined: May 02, 2006
Posts: 1

JTextField TextField = new JextField( 10 );
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/text/DocumentFilter.html
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
well im sure there are set methods for the JTextfield class..

but you could create your own.

like...

public void increaseSize(JTextfield t)
{
// im not sure how to aquire the old size so you can increase by
// how ever much you need to..

}

but somthing along those lines

then you could have a method called

public void checkForNumbers(JTextfield t)
{
String A = t.getText();

for(int i = 0; i<A.length(); i++)
{
//again i don't know what syntax to use.
// but you have to compare each char at A.charAt(i);
// to see if it is an integer or not.
}
}

hope this kinda helps you lol.

-Justin-


You down with OOP? Yeah you know me!
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Moving to the Swing forum.


GenRocket - Experts at Building Test Data
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: JTextField problems