Graphics, AWT, Swing II part
if it is not, do text=text.trim() to remove spaces,
then check text.equals("") to see if it is an empty String
  
Lucio Benfante, Arnaud Berger and Jorge Jordao
 Q: Whats the difference between a Frame and a canvas? Can someone tell me
the difference?
Answer:
A Frame is , well , a frame   a window, with borders,close/minimize/maximize buttons
(usually), and can not contain other elements, such as a menubar ,buttons panels,
etc.
a Canvas is a user interface element (which you can place in e.g. a frame) onto
which you can draw/display something..
  
by Nils O. Selasdal
 Q: I know how to make a text box using Visual Basic that can only accept certain
keys for example if I wanted to make a box where you can type only numbers in it or
letters. However, when it comes to Java I have not been able to figure this out. Is
there a way to do this and make a textbox where you can only type letters in it?
Answer: First of all,  ASCII  is not a synonym for  text . ASCII is just one of many ways
of encoding text to numeric values. It is 7 bit and only includes values from 0 through
127.
Now, on to your question. With ASCII,  numbers  and  letters  are a little easier to
check, since the only letters are  A   Z  and  a   z . However, Java uses Unicode and
has all sorts of fun extra characters.
But you do have a few handy methods on the java.lang.Character class such as
isDigit and isLetter
Now, if you are using swing, then to achieve what I m guessing you want is quite
simple. Just hook a custom text document to the JTextField you re using and have it
do the filtering.
** Here s the part of The Java Tutorial that goes over it
http://java.sun.com/docs/books/tutorial/uiswing/components/textfield.html#validation
Here s someone s Swing FAQ on that
http://users.vnet.net/wwake/swing/faq.html#text_check
Here s a JavaWorld article that describes how to do that to limit the length of input.
Shouldn t be too hard for you to change to your specific needs.
http://www.javaworld.com/javaworld/javaqa/2000 05/02 qa 0512 textbox_p.html
All these links were from the first page of a search on http://www.google.com
Google is your friend!
  
John A.Cruz
 Q: How can I force Java not to draw the background?
file:///F|/a_jsite/350_tips/graphics II.htm (4 of 5) [2001 07 08 11:24:55]






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java web hosting

 

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved