Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DijalogIznajmiFilm extends JDialog {
- private final JPanel contentPanel = new JPanel();
- private Korisnik korisnik;
- public static void main(String[] args) {
- try {
- DijalogIznajmiFilm dialog = new DijalogIznajmiFilm();
- dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
- dialog.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public DijalogIznajmiFilm() {
- setTitle("Iznajmljivanje filma");
- setBounds(100, 100, 450, 300);
- getContentPane().setLayout(new BorderLayout());
- contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
- getContentPane().add(contentPanel, BorderLayout.CENTER);
- contentPanel.setLayout(null);
- Film[] filmovi = FilmController.getList();
- JList<Film>listaFilmova = new JList<Film>(filmovi);
- listaFilmova.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- listaFilmova.setBounds(10, 57, 414, 160);
- contentPanel.add(listaFilmova);
- JLabel lblKorisnik = new JLabel();
- lblKorisnik.setHorizontalAlignment(SwingConstants.CENTER);
- /////////////// ovde puca i javlja null Pointer
- lblKorisnik.setText(korisnik.toString());
- ///////////////
- lblKorisnik.setFont(new Font("Tahoma", Font.PLAIN, 12));
- lblKorisnik.setBounds(10, 11, 414, 35);
- contentPanel.add(lblKorisnik);
- {
- JPanel buttonPane = new JPanel();
- buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
- getContentPane().add(buttonPane, BorderLayout.SOUTH);
- {
- JButton okButton = new JButton("Iznajmi");
- okButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- Film f = (Film) listaFilmova.getSelectedValue();
- if (f == null)
- JOptionPane.showMessageDialog(null, "Morate izabrati film");
- else {
- }
- }
- });
- okButton.setActionCommand("OK");
- buttonPane.add(okButton);
- getRootPane().setDefaultButton(okButton);
- }
- }
- public void setKorisnik(Korisnik korisnik) {
- this.korisnik = korisnik;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement