black.borders.around.my.applet.and.how.to.limit.text.in.TextField


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: black.borders.around.my.applet.and.how.to.limit.text.in.TextField

  1. #1
    Join Date
    Sep 2003
    Posts
    24

    black.borders.around.my.applet.and.how.to.limit.text.in.TextField

    how to make black borders around my applet??
    and if i have TextField 4 example "Name" and a visitor is forbidden to put there more than 10 letters, how to do that?
    Is implementation of KeyListener essential?

  2. #2
    Join Date
    Mar 2003
    Posts
    834
    To draw the black box, couldn't you just obtain the height and width of the applet and then draw a black box from 0,0 to those coordinates (maybe offset by 1, I'm not sure)?
    ArchAngel.
    O:-)

  3. #3
    Join Date
    Sep 2003
    Posts
    24

    thanks

    it works, i have another question.
    A hava a field AGE (Wiek) and the visitor shouldn't have a possibility to input more than 3 numbers, i did it , it works, but the fourth number alway appears for a while.
    Could u take a look at it? I wrote a special class for my TextField :

    class FieldAge extends TextField implements KeyListener {

    boolean Sluchaj(){
    addKeyListener(this);
    return true;
    }
    public void keyReleased(KeyEvent evt)
    {
    String Rob = new String();
    int ile;
    try
    {
    Rob=this.getText();

    }
    catch (Exception e) {
    }
    ile=Rob.length();
    if (ile>3){
    this.setText(Rob.substring(0,3));
    this.setCaretPosition(3);
    return ;
    }
    char znak = evt.getKeyChar();
    int kod = evt.getKeyCode();
    String nazwa = evt.getKeyText(kod);
    }
    public void keyPressed(KeyEvent evt)
    {
    return;
    }

    public void keyTyped(KeyEvent evt)
    {
    return;
    /*char znak = evt.getKeyChar();
    int kod = evt.getKeyCode();
    String nazwa = evt.getKeyText(kod);*/
    }
    FieldAge(){

    super(2);
    this.Sluchaj();
    }

    }
    Attached Files Attached Files

  4. #4
    Join Date
    Sep 2003
    Posts
    24

    thanks

    it works, i have another question.
    A hava a field AGE (Wiek) and the visitor shouldn't have a possibility to input more than 3 numbers, i did it , it works, but the fourth number alway appears for a while.
    Could u take a look at it? I wrote a special class for my TextField :

    class FieldAge extends TextField implements KeyListener {

    boolean Sluchaj(){
    addKeyListener(this);
    return true;
    }
    public void keyReleased(KeyEvent evt)
    {
    String Rob = new String();
    int ile;
    try
    {
    Rob=this.getText();

    }
    catch (Exception e) {
    }
    ile=Rob.length();
    if (ile>3){
    this.setText(Rob.substring(0,3));
    this.setCaretPosition(3);
    return ;
    }
    char znak = evt.getKeyChar();
    int kod = evt.getKeyCode();
    String nazwa = evt.getKeyText(kod);
    }
    public void keyPressed(KeyEvent evt)
    {
    return;
    }

    public void keyTyped(KeyEvent evt)
    {
    return;
    /*char znak = evt.getKeyChar();
    int kod = evt.getKeyCode();
    String nazwa = evt.getKeyText(kod);*/
    }
    FieldAge(){

    super(2);
    this.Sluchaj();
    }

    }
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center