hola no estoy teniendo mucho tiempo pero subo lo que avance del ejercicio 1, faltaría la opción mostrar que la puedes programar en un jlabel o en una pestaña emergente, como tu prefieras, y agrupar los radiobuttom para que solo se seleccione uno, suerte
Pd: Trabajo con eclipce, se que en netbeans es mas facil trabajar con javaswing pero espero que te ayude
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.ButtonGroup;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
import javax.swing.JButton;
import javax.swing.LayoutStyle.ComponentPlacement;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Tarea1 extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
private JPanel contentPane;
private JTextField txtuno;
private JTextField txtdos;
ButtonGroup r = new ButtonGroup();
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Tarea1 frame = new Tarea1();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public Tarea1() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 324, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JLabel lblTitulo = new JLabel("Ingreso de Mascota");
lblTitulo.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblTitulo.setForeground(Color.RED);
lblTitulo.setHorizontalAlignment(SwingConstants.TRAILING);
JLabel lbnombre = new JLabel("Nombre");
JLabel lbrut = new JLabel("Rut amo");
txtuno = new JTextField();
txtuno.setColumns(10);
txtdos = new JTextField();
txtdos.setColumns(10);
JLabel lbsexo = new JLabel("Sexo");
JRadioButton rbmacho = new JRadioButton("Macho");
JRadioButton rbhembra = new JRadioButton("Hembra");
JButton btmostrar = new JButton("Mostrar");
btmostrar.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
JButton btlimpiar = new JButton("Limpiar");
btlimpiar.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
txtuno.setText(null);
txtdos.setText(null);
rbmacho.setSelected(false);
rbhembra.setSelected(false);
}
});
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(31)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addComponent(lblTitulo, GroupLayout.PREFERRED_SIZE, 216, GroupLayout.PREFERRED_SIZE)
.addGroup(gl_contentPane.createSequentialGroup()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING, false)
.addComponent(lbnombre)
.addComponent(lbrut)
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(lbsexo)
.addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(rbmacho))
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(24)
.addComponent(btmostrar)))
.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(Alignment.TRAILING, gl_contentPane.createSequentialGroup()
.addGap(24)
.addComponent(btlimpiar))
.addComponent(txtdos, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(txtuno, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(rbhembra)
.addGap(25)))))
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap()
.addComponent(lblTitulo)
.addGap(27)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lbnombre)
.addComponent(txtuno, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(36)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lbrut)
.addComponent(txtdos, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(37)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lbsexo)
.addComponent(rbmacho)
.addComponent(rbhembra))
.addGap(18)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(btmostrar)
.addComponent(btlimpiar))
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
contentPane.setLayout(gl_contentPane);
}
}