ISBets21MAUBRY
3cf4057e97448d401b49261033b8ab566105944e
ISBets21MAUBRY / eclipse-workspace / ISBets21MAUBRY / src / main / java / gui / CreateEventGUI.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
package gui; import java.awt.Color; import java.awt.Font; import java.awt.Frame; import java.awt.SystemColor; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Calendar; import java.util.Date; import java.util.Locale; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.border.EmptyBorder; import com.toedter.calendar.JCalendar; import businessLogic.BLFacade; import configuration.UtilDate; import domain.AdminUser; import domain.Event; public class CreateEventGUI extends JFrame { private JPanel contentPane; private JTextField textEvento; private static BLFacade facade = LoginGUI.getBusinessLogic(); private Calendar calendarAct = null; private Calendar calendarAnt = null; private AdminUser userlog = null; private JButton btnAtras; private JButton btnCrearEvento = new JButton("Crear evento"); public static void setBusinessLogic(BLFacade pfacade) { facade = pfacade; } public static BLFacade getBusinessLogic() { return facade; } public CreateEventGUI(AdminUser au) { userlog = au; setTitle("Crear evento"); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setBounds(100, 100, 585, 407); contentPane = new JPanel(); contentPane.setBackground(Color.WHITE); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JCalendar jCalendar1 = new JCalendar(); jCalendar1.getDayChooser().getDayPanel().setBackground(Color.WHITE); jCalendar1.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("locale")) { jCalendar1.setLocale((Locale) evt.getNewValue()); } else if (evt.getPropertyName().equals("calendar")) { calendarAnt = (Calendar) evt.getOldValue(); calendarAct = (Calendar) evt.getNewValue(); int monthAnt = calendarAnt.get(Calendar.MONTH); int monthAct = calendarAct.get(Calendar.MONTH); if (monthAct != monthAnt) { if (monthAct == monthAnt + 2) { // Si en JCalendar está 30 de enero y se avanza al mes siguiente, devolverÃa 2 // de marzo (se toma como equivalente a 30 de febrero) // Con este código se dejará como 1 de febrero en el JCalendar calendarAct.set(Calendar.MONTH, monthAnt + 1); calendarAct.set(Calendar.DAY_OF_MONTH, 1); } jCalendar1.setCalendar(calendarAct); } } } }); jCalendar1.setBounds(163, 30, 266, 175); contentPane.add(jCalendar1); JLabel lblNewLabel = new JLabel("Introduzca fecha:"); lblNewLabel.setBounds(41, 115, 103, 14); contentPane.add(lblNewLabel); JLabel lblNewLabel_1 = new JLabel("Introduzca partido:"); lblNewLabel_1.setBounds(41, 242, 113, 14); contentPane.add(lblNewLabel_1); textEvento = new JTextField(); textEvento.setBounds(163, 237, 266, 23); textEvento.setForeground(Color.GRAY); textEvento.setFont(new Font("Arial", Font.PLAIN, 16)); contentPane.add(textEvento); textEvento.setColumns(10); btnCrearEvento.setBackground(SystemColor.textHighlight); btnCrearEvento.setForeground(Color.WHITE); btnCrearEvento.setFont(new Font("Dialog", Font.BOLD, 14)); // btnCrearEvento.setText(ResourceBundle.getBundle("Etiquetas").getString("CreateEvent")); btnCrearEvento.setText("CreateEvent"); btnCrearEvento.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Date date = UtilDate.trim(new Date(jCalendar1.getCalendar().getTime().getTime())); if (textEvento.getText().equals("")) { JOptionPane.showMessageDialog(getContentPane(), "El evento no puede estar vacío", "Error", JOptionPane.ERROR_MESSAGE); } else { Event ev = new Event(facade.getMaxIdInDB() + 1, textEvento.getText(), date); boolean exist = facade.existEvent(ev); if (exist == false) { boolean ins = facade.insertEvent(ev); if (ins) { JOptionPane.showMessageDialog(contentPane, "Evento añadido correctamente"); } else { JOptionPane.showMessageDialog(contentPane, "No se ha podido añadir el evento"); } Frame gui = new MainAdminGUI(userlog); gui.setAlwaysOnTop(true); gui.setVisible(true); close(); } else { JOptionPane.showMessageDialog(contentPane, "Evento ya existente"); } } } }); btnCrearEvento.setBounds(220, 310, 145, 23); contentPane.add(btnCrearEvento); btnAtras = new JButton(); btnAtras.setBackground(SystemColor.controlShadow); btnAtras.setForeground(Color.WHITE); btnAtras.setFont(new Font("Dialog", Font.BOLD, 14)); // btnAtras.setText(ResourceBundle.getBundle("Etiquetas").getString("Close")); btnAtras.setText("Close"); btnAtras.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { Frame fr = new MainAdminGUI(userlog); fr.setAlwaysOnTop(true); fr.setVisible(true); dispose(); } }); btnAtras.setBounds(12, 310, 113, 23); contentPane.add(btnAtras); } public void close() { this.setVisible(false); } } |
Commits for ISBets21MAUBRYeclipse-workspace/ISBets21MAUBRY/src/main/java/gui/CreateEventGUI.java
Revision | Author | Commited | Message |
---|---|---|---|
3cf405 ... | porkipig | Sun 16 May, 2021 19:27:29 +0000 | Iteración 3(Versión sin idiomas) |