• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

JTextField problems  RSS feed

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

JTextField TextField = new JextField( 10 );
 
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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-
 
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the Swing forum.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!