Interface Grafica Help!

3 respostas
Glleydson

Ola minha sinceras pelo o outro topico mas enfim se poderem ajudar e gostaria de saber como faco para dar espaco entre os botoes ja tentei aqui nao consigo se alguem poder me dar uma luz eo agradeço muito.

import java.awt.*;
import javax.swing.*;

public class Programa_calculos extends JFrame {

    JLabel lb_titulo, lb_numero, lb_resultado;
    JTextField tf_numero, tf_resultado;
    JButton bt_parimpar, bt_fatorial, bt_primo, bt_raiz;
    JPanel pCenter, pSul;

    public Programa_calculos() {
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setTitle("PROGRAMA DE CALCULOS");
        setLayout(new BorderLayout());

        //NORTE
        lb_titulo = new JLabel("PROGRAMA DE CALCULOS");
        lb_titulo.setHorizontalAlignment(SwingConstants.CENTER);
        add(lb_titulo, BorderLayout.NORTH);

        //CENTER
        lb_numero = new JLabel("NUMERO:");
        tf_numero = new JTextField();
        bt_parimpar = new JButton("PAR/IMPAR");
        bt_primo = new JButton("PRIMO");
        bt_fatorial = new JButton("FATORIAL");
        bt_raiz = new JButton("RAIZ");
        pCenter = new JPanel(new GridLayout(3, 2));
        pCenter.add(lb_numero);
        pCenter.add(tf_numero);
        pCenter.add(bt_primo);
        pCenter.add(bt_parimpar);
        pCenter.add(bt_fatorial);
        pCenter.add(bt_raiz);
        pCenter.add(bt_raiz);
        add(pCenter, BorderLayout.CENTER);

        //SUL
        lb_resultado = new JLabel("RESULTADO");
        tf_resultado = new JTextField();
        pSul = new JPanel(new GridLayout(1, 2));
        pSul.add(lb_resultado);
        pSul.add(tf_resultado);
        add(pSul, BorderLayout.SOUTH);


        setVisible(true);
        setResizable(true);
        pack();

    }

    public static void main(String[] args) {
        new Programa_calculos();
    }
}

3 Respostas

L

Veja como faz e tente implementar no seu codigo

JLabel L3 = new JLabel(); L3.setText("exemplo: "); L3.setSize(200, 35);

valeu abrxx!

Glleydson

Um legal brother fiz um teste aki e bem parecido com o setBounds…vc consegue manipular em qualquer lugar…

Glleydson

Mas da para manipular o JPanel em quaquer lugar ?

Criado 27 de maio de 2011
Ultima resposta 27 de mai. de 2011
Respostas 3
Participantes 2