//package proyect; //package pruebas; import java.io.*; import java.awt.*; import java.util.*; import java.awt.event.*; import javax.swing.*; /** * *

Title:Prueba

*

Description:

*

Copyright: Copyright (c) 2004

*

Company:

* @author not attributable * @version 1.0 */ public class Prueba extends JFrame implements ActionListener { /** * genera la prueba */ public Prueba() { super("JFrame de Prueba "); header = new JLabel("AGREGAR MENSAJE"); usuarioLabel = new JLabel("Su nombre:"); mailpLabel = new JLabel("Su e-mail:"); maildLabel = new JLabel("e-mail destinatario:"); mensajeLabel = new JLabel("Mensaje:"); annoLabel = new JLabel("Seleccione el Anno:"); antesLabel = new JLabel("Seleccione los dias de anticipacion del aviso:"); mesLabel = new JLabel("Seleccione el Mes:"); diaLabel = new JLabel("Fecha del Evento a Recordar... seleccione el Dia:"); // sexLabel = new JLabel("Sexo:"); usuario = new JTextField(); mailp = new JTextField(); maild = new JTextField(); mensaje = new JTextField(); // anno = new JTextField(); annoListModel = new DefaultListModel(); annoListModel.addElement("2004"); annoListModel.addElement("2005"); annoListModel.addElement("2006"); annoListModel.addElement("2007"); annoList = new JList(annoListModel); annoList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); annoList.setSelectedIndex(0); annoListScroll = new JScrollPane(annoList); antesListModel = new DefaultListModel(); antesListModel.addElement("0"); antesListModel.addElement("1"); antesListModel.addElement("2"); antesListModel.addElement("3"); antesListModel.addElement("4"); antesListModel.addElement("5"); antesListModel.addElement("6"); antesListModel.addElement("7"); antesListModel.addElement("8"); antesListModel.addElement("9"); antesListModel.addElement("10"); antesListModel.addElement("11"); antesListModel.addElement("12"); antesListModel.addElement("13"); antesListModel.addElement("14"); antesListModel.addElement("15"); antesListModel.addElement("16"); antesListModel.addElement("17"); antesListModel.addElement("18"); antesListModel.addElement("19"); antesListModel.addElement("20"); antesListModel.addElement("21"); antesListModel.addElement("22"); antesListModel.addElement("23"); antesListModel.addElement("24"); antesListModel.addElement("25"); antesListModel.addElement("26"); antesListModel.addElement("27"); antesListModel.addElement("28"); antesListModel.addElement("29"); antesList = new JList(antesListModel); antesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); antesList.setSelectedIndex(0); antesListScroll = new JScrollPane(antesList); mesListModel = new DefaultListModel(); mesListModel.addElement("1"); mesListModel.addElement("2"); mesListModel.addElement("3"); mesListModel.addElement("4"); mesListModel.addElement("5"); mesListModel.addElement("6"); mesListModel.addElement("7"); mesListModel.addElement("8"); mesListModel.addElement("9"); mesListModel.addElement("10"); mesListModel.addElement("11"); mesListModel.addElement("12"); // mesListModel.addElement("13"); mesList = new JList(mesListModel); mesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); mesList.setSelectedIndex(0); mesListScroll = new JScrollPane(mesList); // dia = new JTextField(); diaListModel = new DefaultListModel(); diaListModel.addElement("1"); diaListModel.addElement("2"); diaListModel.addElement("3"); diaListModel.addElement("4"); diaListModel.addElement("5"); diaListModel.addElement("6"); diaListModel.addElement("7"); diaListModel.addElement("8"); diaListModel.addElement("9"); diaListModel.addElement("10"); diaListModel.addElement("11"); diaListModel.addElement("12"); diaListModel.addElement("13"); diaListModel.addElement("14"); diaListModel.addElement("15"); diaListModel.addElement("16"); diaListModel.addElement("17"); diaListModel.addElement("18"); diaListModel.addElement("19"); diaListModel.addElement("20"); diaListModel.addElement("21"); diaListModel.addElement("22"); diaListModel.addElement("23"); diaListModel.addElement("24"); diaListModel.addElement("25"); diaListModel.addElement("26"); diaListModel.addElement("27"); diaListModel.addElement("28"); diaListModel.addElement("29"); diaListModel.addElement("30"); diaListModel.addElement("31"); // mesListModel.addElement("Todos los meses"); diaList = new JList(diaListModel); diaList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); diaList.setSelectedIndex(0); diaListScroll = new JScrollPane(diaList); /* maleSex = new JRadioButton("Masculino", true); femaleSex = new JRadioButton("Femenino", false); sexGroup = new ButtonGroup(); sexGroup.add(maleSex); sexGroup.add(femaleSex); */ saveButton = new JButton("Guardar"); closeButton = new JButton("Cerrar"); //nameLabel = new JLabel("Nombre: "); //nameLabel.setLabelFor(name); usuario.setSize(100, 30); saveButton.addActionListener(this); closeButton.addActionListener(this); JPanel centerPane = new JPanel(); GridLayout gridLayout = new GridLayout(11, 2, 10, 10); centerPane.setLayout(gridLayout); centerPane.add(usuarioLabel); centerPane.add(usuario); centerPane.add(mailpLabel); centerPane.add(mailp); centerPane.add(maildLabel); centerPane.add(maild); centerPane.add(mensajeLabel); centerPane.add(mensaje); centerPane.add(diaLabel); centerPane.add(diaListScroll); centerPane.add(mesLabel); centerPane.add(mesListScroll); centerPane.add(annoLabel); //centerPane.add(anno); centerPane.add(annoListScroll); centerPane.add(antesLabel); centerPane.add(antesListScroll); // centerPane.add(dia); // centerPane.add(sexLabel); // centerPane.add(maleSex); // centerPane.add(new JLabel("")); // centerPane.add(femaleSex); centerPane.add(saveButton); centerPane.add(closeButton); JPanel contentPane = new JPanel(); BorderLayout borderLayout = new BorderLayout(); contentPane.setLayout(borderLayout); this.setContentPane(contentPane); this.getContentPane().add(header, BorderLayout.NORTH); this.getContentPane().add(centerPane, BorderLayout.CENTER); this.setSize(750, 500); this.setVisible(true); } public void actionPerformed(ActionEvent e) { ABC abc = new ABC("agenda.dat"); Evento evento = new Evento(); if ((e.getSource()).equals(saveButton)) { evento.setUsuario(usuario.getText()); evento.setMailp(mailp.getText()); evento.setMaild(maild.getText()); evento.setMensaje(mensaje.getText()); // evento.setAnno(anno.getText()); evento.setAnno((String)(annoList.getSelectedValue())); evento.setAntes((String)(antesList.getSelectedValue())); evento.setMes((String)(mesList.getSelectedValue())); evento.setDia((String)(diaList.getSelectedValue())); // evento.setDia(dia.getText()); /* if(maleSex.isSelected()) evento.setSex(maleSex.getText()); else evento.setSex(femaleSex.getText()); */ abc.addEvento(evento); System.out.println("El objeto ha sido serializado y guardado en agenda.dat \n"); } else if((e.getSource()).equals(closeButton)) { this.setVisible(false); } else System.out.println("El objeto no ha sido guardado \n"); } private JTextField usuario; private JTextField mailp; private JTextField maild; private JTextField mensaje; // private JTextField anno; private JList annoList; private DefaultListModel annoListModel; private JScrollPane annoListScroll; private JList antesList; private DefaultListModel antesListModel; private JScrollPane antesListScroll; private JList mesList; private DefaultListModel mesListModel; private JScrollPane mesListScroll; private JList diaList; private DefaultListModel diaListModel; private JScrollPane diaListScroll; // private JTextField dia; // private ButtonGroup sexGroup; // private JRadioButton maleSex; // private JRadioButton femaleSex; private JButton saveButton; private JButton closeButton; private JLabel header; private JLabel usuarioLabel; private JLabel mailpLabel; private JLabel maildLabel; private JLabel mensajeLabel; private JLabel annoLabel; private JLabel antesLabel; private JLabel mesLabel; private JLabel diaLabel; // private JLabel sexLabel; }