How to determine the size of a JTextField?

0

I'm doing a program involving Pythagorean theorem, and wanted to leave a triangle in the middle, with three JTextFields around all three sides of it. I did this, but the problem is that when I create the JTextField and add it to the desired Container, it gets huge. It is a very large white rectangle that when I click to type, a small letter comes out. So, my question is: How can I resize this JTextField to decrease it and avoid unnecessary sizes?

    
asked by anonymous 20.07.2014 / 12:36

1 answer

-1

Try to use setBounds , see here .

Example:

public void teste()
    {
        //posição da caixa de texto no eixo horizontal em pixeis 
        int posX = 10;

        //posição da caixa de texto no eixo vertical em pixeis 
        int posY = 10;

        //largura da caixa de texto em pixeis
        int largura = 10;

         //altura da caixa de texto em pixeis
        int altura = 10;
        //é necessário instanciar antes o objecto
        JTextField cxaTexto = new JTextField();

        cxaTexto.setBounds(posX, posY, largura, altura);
    }
    
23.07.2014 / 18:54