Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //archivo PanelAgregarPelicula.java
- //va dentro de la funcion public void dibujarPanel(), debajo del aporte 4
- JLabel lblGenero = new JLabel("Genero");
- lblGenero.setFont(fuentePred);
- GridBagConstraints gbc_lblGenero = new GridBagConstraints();
- gbc_lblGenero.insets = new Insets(0, 0, 5, 5);
- gbc_lblGenero.gridx = 1;
- gbc_lblGenero.gridy = 3;
- gbc_lblGenero.fill = GridBagConstraints.HORIZONTAL;
- add(lblGenero, gbc_lblGenero);
- cbGenero = new JComboBox<Categoria>();
- GridBagConstraints gbc_cbGenero = new GridBagConstraints();
- cbGenero.setFont(fuentePred);
- cbGenero.addItem(new Categoria("Seleccione un genero"));
- cbGenero.addItem(new Categoria("Terror"));
- cbGenero.addItem(new Categoria("Accion"));
- cbGenero.addItem(new Categoria("Suspenso"));
- cbGenero.addItem(new Categoria("Romantica"));
- gbc_cbGenero.insets = new Insets(0, 0, 5, 5);
- gbc_cbGenero.fill = GridBagConstraints.HORIZONTAL;
- gbc_cbGenero.gridx = 3;
- gbc_cbGenero.gridy = 3;
- add(cbGenero, gbc_cbGenero);
- btnNewButton = new JButton("Aceptar");
- btnNewButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if(!txtNombre.getText().isEmpty()) {
- if(cbGenero.getSelectedIndex() != 0) {
- Categoria seleccion = (Categoria) cbGenero.getSelectedItem();
- Pelicula Nueva = new Pelicula(txtNombre.getText().toString(),seleccion.getNombre());
- listPeliculas.addElement(Nueva);
- txtNombre.setText("");
- lblProxID.setText(String.valueOf(Pelicula.getProxId()));
- cbGenero.setSelectedIndex(0);
- }
- else
- {
- JOptionPane.showMessageDialog(null, "Debe seleccionar un genero");
- }
- }
- else
- {
- JOptionPane.showMessageDialog(null, "Debe ingresar un nombre");
- }
- }
- });
- btnNewButton.setBackground(new Color(129, 208, 252));
- btnNewButton.setFont(fuentePred);
- GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
- gbc_btnNewButton.insets = new Insets(0, 0, 5, 5);
- gbc_btnNewButton.gridx = 1;
- gbc_btnNewButton.gridy = 5;
- add(btnNewButton, gbc_btnNewButton);
- }
- public void setDefaultListModel(DefaultListModel<Pelicula> listPeliculaslRecibida) {
- this.listPeliculas = listPeliculaslRecibida;
- }
- }
- //archivo PanelListadoPeliculas.java
- package Paquete;
- import java.awt.GridBagConstraints;
- import java.awt.GridBagLayout;
- import java.awt.Insets;
- import java.util.Comparator;
- import java.util.TreeSet;
- import javax.swing.DefaultListModel;
- import javax.swing.JList;
- import javax.swing.JPanel;
- import javax.swing.JScrollPane;
- import javax.swing.JLabel;
- import java.awt.Dimension;
- import java.awt.Font;
- public class PanelListadoPeliculas extends JPanel {
- private static final long serialVersionUID = 1L;
- private JScrollPane scrollPane;
- private JList<Pelicula> listaPeliculasJL;
- private DefaultListModel<Pelicula> listPeliculas;
- public PanelListadoPeliculas() {
- dibujarPanel();
- }
- public void dibujarPanel() {
- GridBagLayout gridBagLayout = new GridBagLayout();
- gridBagLayout.columnWidths = new int[]{80, 0, 0, 0, 30, 0};
- gridBagLayout.rowHeights = new int[]{30, 63, 0, 0, 30, 0};
- gridBagLayout.columnWeights = new double[]{0.0, 1.0, 0.0, 1.0, 0.0, Double.MIN_VALUE};
- gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE};
- setLayout(gridBagLayout);
- // aca va el aporte 6
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement