esta classe atualizada recibo3
package com.recibo.Recibo;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.DropMode;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.FormSpecs;
import com.jgoodies.forms.layout.RowSpec;
public class Recibo3 extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
private JPanel contentPane;
private JTextField txtid;
private JTextField txtnome;
private JTextField txtvalor;
private JButton bt_enviar;
private int id;
private String nome;
private double Valor;
public boolean validador;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Recibo3 frame = new Recibo3();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public Recibo3() {
setOpacity(20.1f);
setTitle("Recibo");
setAlwaysOnTop(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(new FormLayout(
new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(49dlu;default)"),
FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
ColumnSpec.decode("default:grow"), },
new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
FormSpecs.DEFAULT_ROWSPEC, }));
JLabel labeid = new JLabel("Codigo :");
getContentPane().add(labeid, "4, 4, right, default");
getId();
txtid = new JTextField();
txtid.setDropMode(DropMode.ON);
getContentPane().add(txtid, "6, 4, left, bottom");
txtid.setColumns(10);
JLabel labelnome = new JLabel("Nome beneficiario:");
labelnome.setLabelFor(txtnome);
getContentPane().add(labelnome, "4, 6, right, default");
txtnome = new JTextField();
getContentPane().add(txtnome, "6, 6, left, default");
txtnome.setColumns(20);
getNome();
JLabel labelvalor = new JLabel("valor");
labelvalor.setLabelFor(txtvalor);
getContentPane().add(labelvalor, "4, 8, right, fill");
txtvalor = new JTextField();
getContentPane().add(txtvalor, "6, 8, left, default");
txtvalor.setColumns(10);
getValor();
bt_enviar = new JButton("Enviar");
bt_enviar.setVerticalAlignment(SwingConstants.TOP);
contentPane.add(bt_enviar, "6, 10, left, bottom");
bt_enviar.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
id = Integer.parseInt(txtid.getText());
nome = txtnome.getText().toString();
Valor = Double.parseDouble(txtvalor.getText());
BancoDados recibo = new BancoDados();
if (validador = false) {
id = 0;
nome = " ";
Valor = 0;
} else
validador = true;
try {
recibo.inserirRecibo(id, nome, Valor);
} catch (Exception p) {
System.out.println("Erro" + p.getMessage());
}
}
});
}
public int getId() {
return id;
}
public String getNome() {
return nome;
}
public double getValor() {
return Valor;
}
}
Então eu uso windowbulder no eclipse, não sei terei que outro layout, swing normalmente complicado você precisar layout fique certinho.
FormLayout do pacote JGoodies.
se caso tenha eclipe e extensao windosBuilder instalado tenta ai exercuta ai.