Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package es.uca.gii.csi.sauron.gui;
- import javax.swing.JInternalFrame;
- public class IfrSala extends JInternalFrame {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private JTextField _txtNombre;
- private JTextField _txtEslogan;
- private JButton _butSave;
- private Sala _sala = null;
- private JLabel _lblCapacidadActual;
- private JTextField _txtCapacidadActual;
- /**
- * Create the frame.
- */
- public IfrSala(Sala sala) {
- //Doble clic en búsqueda
- if(sala != null){
- _sala = sala;
- _txtNombre = new JTextField(_sala.getNombre());
- _txtEslogan = new JTextField(_sala.getEslogan());
- _txtCapacidadActual = new JTextField(Integer.toString(sala.getCapacidadActual()));
- JOptionPane.showMessageDialog(null, "Funciona, Sala: " + _txtNombre.getText());
- }
- //
- setClosable(true);
- setResizable(true);
- setTitle("Sala");
- setBounds(100, 100, 450, 300);
- getContentPane().setLayout(new FormLayout(new ColumnSpec[] {
- 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,
- 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 lblNombre = new JLabel("Nombre");
- getContentPane().add(lblNombre, "2, 4, right, default");
- _txtNombre = new JTextField();
- getContentPane().add(_txtNombre, "4, 4, fill, default");
- _txtNombre.setColumns(10);
- JLabel lblEslogan = new JLabel("Eslogan");
- getContentPane().add(lblEslogan, "2, 6, right, default");
- _txtEslogan = new JTextField();
- getContentPane().add(_txtEslogan, "4, 6, fill, default");
- _txtEslogan.setColumns(10);
- _lblCapacidadActual = new JLabel("Capacidad Actual");
- getContentPane().add(_lblCapacidadActual, "2, 8, right, default");
- _txtCapacidadActual = new JTextField();
- getContentPane().add(_txtCapacidadActual, "4, 8, fill, default");
- _txtCapacidadActual.setColumns(10);
- _butSave = new JButton("Guardar");
- _butSave.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if(_sala == null)
- try {
- _sala = Sala.Create(Integer.parseInt(_txtCapacidadActual.getText()), _txtNombre.getText(), _txtEslogan.getText(), null);
- } catch (Exception e1){
- JOptionPane.showMessageDialog(null, "¡Error al crear la sala!");
- }
- else{
- _sala.setNombre(_txtNombre.getText());
- _sala.setEslogan(_txtEslogan.getText());
- _sala.setCapacidadActual(Integer.parseInt(_txtCapacidadActual.getText()));
- try {
- _sala.Update();
- } catch (Exception e1) {
- JOptionPane.showMessageDialog(null, "¡Error al actualizar la sala!");
- }
- }
- }
- });
- getContentPane().add(_butSave, "2, 12, 3, 1");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement