Ejemplo n.º 1
0
  public Initialize() {
    setTitle("");
    setSize(400, 300);
    setLocationRelativeTo(null);
    JPanel p = new JPanel();
    p.setLayout(new GridLayout(3, 2));
    typel = new JLabel("Animal Type:");
    typef = new JComboBox();
    typef.addItem("Cow");
    typef.addItem("Deer");
    typef.addItem("Horse");
    tot_popl = new JLabel("Initial population:");
    tot_pop = new JTextField(12);
    annuler = new JButton("Cancel");
    validate = new JButton("Create");

    annuler.addActionListener(this);
    validate.addActionListener(this);
    p.add(typel);
    p.add(typef);
    p.add(tot_popl);
    p.add(tot_pop);
    p.add(annuler);
    p.add(validate);
    setContentPane(p);
    this.pack(); // bien regrouper les éléments
  }
  public CadastrarPassageiro(int i, String tipoPassageiro) {
    limit = i;
    bn = Util.getBundle();
    this.passageiroDAO = new PassageiroDAO();
    passagem = new Passagem();
    passagemDAO = new PassagemDAO();
    painel = new Janela();

    // joga no frame pq o passageiro precisa saber seu cod.

    sTipoPassageiro = tipoPassageiro;
    layout = new GridBagLayout();
    painel.setLayout(layout);
    gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(5, 10, 0, 0);

    lbCodPas = new Rotulo(bn.getString("menuCadastrarPassageiro.bilhete"));

    lbNome = new Rotulo(bn.getString("menuCadastrarPassageiro.lbNome"));
    lbSobrenome = new Rotulo(bn.getString("menuCadastrarPassageiro.lbSobrenome"));
    lbDataNascimento = new Rotulo(bn.getString("menuCadastrarPassageiro.lbDataNascimento"));
    lbEmail = new Rotulo(bn.getString("menuCadastrarPassageiro.lbEmail"));
    lbTelefone = new Rotulo(bn.getString("menuCadastrarPassageiro.lbTelefone"));
    lbCpf = new Rotulo(bn.getString("menuCadastrarPassageiro.lbCpf"));
    lbFormaTratamento = new Rotulo(bn.getString("menuCadastrarPassageiro.lbFormaTratamento"));
    lbTipo = new Rotulo(bn.getString("menuCadastrarPassageiro.lbTipo"));

    btProximo = new Botao(bn.getString("menuComprarPassagem.btProximo"));
    btProximo.setPreferredSize(new Dimension(90, 40));
    btProximo.addActionListener(this);
    btCancelar = new Botao(bn.getString("menuComprarPassagem.btCancelar"));
    btCancelar.setPreferredSize(new Dimension(90, 40));
    btCancelar.addActionListener(this);
    btVoltar = new Botao(bn.getString("menuComprarPassagem.btVoltar"));
    btVoltar.setPreferredSize(new Dimension(90, 40));
    btVoltar.addActionListener(this);

    cTipoPassageiro = new ComboBox("Adulto");
    cTipoPassageiro.addItem(bn.getString("menuCadastrarPassageiro.adulto"));
    cTipoPassageiro.addItem(bn.getString("menuCadastrarPassageiro.crianca"));
    cTipoPassageiro.addItem(bn.getString("menuCadastrarPassageiro.bebe"));

    cFormaTratamento = new ComboBox("Sr");
    cFormaTratamento.addItem(bn.getString("menuCadastrarPassageiro.sra"));
    cFormaTratamento.addItem(bn.getString("menuCadastrarPassageiro.sr"));
    cFormaTratamento.addItem(bn.getString("menuCadastrarPassageiro.srta"));

    txNome = new CaixaDeTexto();
    txSobrenome = new CaixaDeTexto();
    txDataNascimento = new JFormattedTextField(Mascara("##/##/####"));
    txEmail = new CaixaDeTexto();
    txTelefone = new CaixaDeTexto();
    txCpf = new CaixaDeTexto();
    txTipo = new CaixaDeTexto();
    passagem = passagemDAO.getCodPassagem(limit);
    txCodPas = new CaixaDeTexto();
    txCodPas.setEditable(false);
    txCodPas.setText("" + passagem.getCodPas());
    txTipo.setEditable(false);
    txTipo.setText(sTipoPassageiro);
    // lbNome
    gbc.gridy = 0; // coluna
    gbc.gridx = 0; // linha
    layout.setConstraints(lbNome, gbc);
    painel.add(lbNome);

    // txNome
    gbc.gridy = 0; // coluna
    gbc.gridx = 1; // linha
    layout.setConstraints(txNome, gbc);
    painel.add(txNome);

    // lbsobrenome
    gbc.gridy = 1; // coluna
    gbc.gridx = 0; // linha
    layout.setConstraints(lbSobrenome, gbc);
    painel.add(lbSobrenome);

    // txSobrenome
    gbc.gridy = 1; // coluna
    gbc.gridx = 1; // linha
    layout.setConstraints(txSobrenome, gbc);
    painel.add(txSobrenome);

    // lbDatanasci
    gbc.gridy = 2; // coluna
    gbc.gridx = 0; // linha
    layout.setConstraints(lbDataNascimento, gbc);
    painel.add(lbDataNascimento);

    // txDataNasci
    gbc.gridy = 2; // coluna
    gbc.gridx = 1; // linha
    layout.setConstraints(txDataNascimento, gbc);
    painel.add(txDataNascimento);

    // lbTelefone
    gbc.gridy = 3; // coluna
    gbc.gridx = 0; // linha
    layout.setConstraints(lbTelefone, gbc);
    painel.add(lbTelefone);

    // txTelefone
    gbc.gridy = 3; // coluna
    gbc.gridx = 1; // linha
    layout.setConstraints(txTelefone, gbc);
    painel.add(txTelefone);

    // lbCpf
    gbc.gridy = 4; // coluna
    gbc.gridx = 0; // linha
    layout.setConstraints(lbCpf, gbc);
    painel.add(lbCpf);

    // txCpf
    gbc.gridy = 4; // coluna
    gbc.gridx = 1; // linha
    layout.setConstraints(txCpf, gbc);
    painel.add(txCpf);

    // lbEmail
    gbc.gridy = 5; // coluna
    gbc.gridx = 0; // linha
    layout.setConstraints(lbEmail, gbc);
    painel.add(lbEmail);

    // txEmail
    gbc.gridy = 5; // coluna
    gbc.gridx = 1; // linha
    layout.setConstraints(txEmail, gbc);
    painel.add(txEmail);

    // lbTipo
    gbc.gridy = 6; // coluna
    gbc.gridx = 0; // linha
    layout.setConstraints(lbTipo, gbc);
    painel.add(lbTipo);

    // txCpf
    gbc.gridy = 6; // coluna
    gbc.gridx = 1; // linha
    layout.setConstraints(txTipo, gbc);
    painel.add(txTipo);

    // lbFormaTratamento
    gbc.gridy = 7; // coluna
    gbc.gridx = 0; // linha
    layout.setConstraints(lbFormaTratamento, gbc);
    painel.add(lbFormaTratamento);

    // cFormaTratamento
    gbc.gridy = 7; // coluna
    gbc.gridx = 1; // linha
    layout.setConstraints(cFormaTratamento, gbc);
    painel.add(cFormaTratamento);

    gbc.gridy = 8; // coluna
    gbc.gridx = 0; // linha
    layout.setConstraints(lbCodPas, gbc);
    painel.add(lbCodPas);
    gbc.gridy = 8; // coluna
    gbc.gridx = 1; // linha
    layout.setConstraints(txCodPas, gbc);
    painel.add(txCodPas);

    // botoes
    gbc.gridy = 9;
    gbc.gridx = 2;

    JPanel botoes = new JPanel(new FlowLayout());
    botoes.setBackground(minhaCor);
    botoes.add(btVoltar);
    botoes.add(btProximo);
    botoes.add(btCancelar);
    layout.setConstraints(botoes, gbc);
    painel.add(botoes);

    painel.setLocationRelativeTo(null);
    painel.setTitle(bn.getString("menuCadastrarPassageiro.titulo"));
    painel.setVisible(true);
    int op = painel.getDefaultCloseOperation(); // HIDE_ON_CLOSE
    painel.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    // painel.setResizable(false);
  }
Ejemplo n.º 3
0
  /**
   * This is the constructor for objects of the class ChangeReservationDialog
   *
   * @param markedSeats A collection of the seats marked in the room overview
   * @param show The show chosen in the result table
   * @param customerID The phonenumber of the customer
   * @param frame The frame the dialog was called from
   */
  public ChangeReservationDialog(
      ArrayList<Seat> markedSeats, Show show, int customerID, MainFrame frame) {
    super("Reservation");

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    Border standart = BorderFactory.createEmptyBorder(5, 5, 5, 5);
    JPanel north = new JPanel();
    north.setBorder(standart);
    contentPane.add(north, BorderLayout.NORTH);

    JLabel topText =
        new JLabel(
            "Du forsøger at ændre en reservation til en med følgende "
                + markedSeats.size()
                + " sæder til: "
                + show.toString());
    north.add(topText);

    JPanel center = new JPanel();
    center.setLayout(new FlowLayout());
    center.setBorder(standart);
    contentPane.add(center, BorderLayout.CENTER);
    String seatString = "<html>";
    for (Seat s : markedSeats) {
      seatString += s.toString() + "<br>";
    }
    seatString += "</html>";
    JLabel seatText = new JLabel(seatString);
    seatText.setBackground(Color.WHITE);
    center.add(seatText);

    JPanel south = new JPanel();
    south.setLayout(new BorderLayout());
    south.setBorder(standart);
    contentPane.add(south, BorderLayout.SOUTH);

    JPanel phoneSection = new JPanel();
    JLabel costumerText = new JLabel("Kundens telefonnummer: " + customerID);
    phoneSection.add(costumerText);

    JPanel buttons = new JPanel();
    JButton cancel = new JButton("Annuller");
    cancel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        });
    JButton reserve = new JButton("Ændre");
    reserve.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {

            String number = "" + customerID;

            if (number.length() == 8) {
              Database.deleteReservations(show, customerID);
              for (Seat s : markedSeats) {
                Database.makeReservation(show, new Customer(Integer.parseInt(number)), s);
              }

              ChangeReservationDialog.this.dispose();
              frame.reset();
            }
          }
        });
    buttons.add(cancel);
    buttons.add(reserve);

    south.add(buttons, BorderLayout.SOUTH);

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    pack();
    setVisible(true);
  }
Ejemplo n.º 4
0
  public void setContent(String cat) {
    cat = cat.trim();
    selectAllCB.setVisible(false);
    selectAllCB.setSelected(false);
    deleteBut.setVisible(false);
    restoreBut.setVisible(false);
    refreshBut.setVisible(true);
    Object columns[] = null;
    int count = 0;
    switch (cat) {
      case "Inbox":
        columns = new Object[] {"", "From", "Date", "Subject", "Content"};
        count = Database.getCount("Inbox");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='inbox' ORDER BY msg_id desc");
        ;
        break;
      case "SentMail":
        columns = new Object[] {"", "To", "Date", "Subject", "Content"};
        count = Database.getCount("Sentmail");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='sentmail' ORDER BY msg_id desc");
        break;
      case "Draft":
        columns = new Object[] {"", "To", "Date", "Subject", "Content"};
        count = Database.getCount("Draft");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='draft' ORDER BY msg_id desc");
        break;
      case "Outbox":
        columns = new Object[] {"", "To", "Date", "Subject", "Content"};
        count = Database.getCount("Outbox");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='outbox' ORDER BY msg_id desc");
        break;
      case "Trash":
        //                restoreBut.setVisible(true);
        columns = new Object[] {"", "To/From", "Date", "Subject", "Content"};
        count = Database.getCount("Trash");
        workingSet =
            db.getData(
                "SELECT * FROM messages,trash WHERE messages.tag='trash' and messages.msg_id=trash.msg_id ORDER BY deleted_at desc");
        break;
      default:
        System.out.println("in default case");
    }
    if (count > 0) {
      selectAllCB.setVisible(true);
      rows = new Object[count][];
      msgID = new int[count];
      try {
        workingSet.beforeFirst();
        for (int i = 0; i < count && workingSet.next(); i++) {
          msgID[i] = workingSet.getInt(1);
          rows[i] =
              new Object[] {
                false,
                workingSet.getString(2),
                workingSet.getDate(3),
                workingSet.getString(4),
                workingSet.getString(5)
              };
        }
      } catch (SQLException sqlExc) {
        JOptionPane.showMessageDialog(null, sqlExc, "EXCEPTION", JOptionPane.ERROR_MESSAGE);
        sqlExc.printStackTrace();
      }

      tableModel = new MyDefaultTableModel(rows, columns);
      table = new JTable(tableModel);
      table.getSelectionModel().addListSelectionListener(this);
      table.addMouseListener(this);
      table.getTableHeader().setOpaque(true);
      table.getTableHeader().setReorderingAllowed(false);
      //            table.getTableHeader().setBackground(Color.blue);
      table.getTableHeader().setForeground(Color.blue);
      //        table.setRowSelectionAllowed(false);
      //            table.setColumnSelectionAllowed(false);
      table.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 14));
      table.setRowHeight(20);
      table.setFillsViewportHeight(true);

      TableColumn column = null;
      for (int i = 0; i < 5; i++) {
        column = table.getColumnModel().getColumn(i);
        if (i == 0) {
          column.setPreferredWidth(6);
        } else if (i == 3) {
          column.setPreferredWidth(250);
        } else if (i == 4) {
          column.setPreferredWidth(450);
        } else {
          column.setPreferredWidth(40);
        }
      }
      table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);

      remove(contentPan);
      contentPan = new JScrollPane(table);
      contentPan.setBackground(Color.orange);
      contentPan.setOpaque(true);
      contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
      add(contentPan, "Center");
      Home.home.homeFrame.setVisible(true);
    } else {
      JPanel centPan = new JPanel(new GridBagLayout());
      centPan.setBackground(new Color(52, 86, 70));
      JLabel label = new JLabel("No Messages In This Category");
      label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 22));
      label.setForeground(Color.orange);
      centPan.add(label);
      remove(contentPan);
      contentPan = new JScrollPane(centPan);
      contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
      add(contentPan, "Center");
      contentPan.repaint();
    }
  }
Ejemplo n.º 5
0
  public void createGUI() {
    setLayout(new BorderLayout());
    toolBar = new JToolBar("options", JToolBar.HORIZONTAL);
    toolBar.setFloatable(false);
    toolBar.setOpaque(true);
    toolBar.setBackground(new Color(154, 12, 12));
    toolBar.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15));
    selectAllCB = new JCheckBox("Select All");
    selectAllCB.setVisible(false);
    selectAllCB.setForeground(Color.white);
    selectAllCB.addActionListener(this);
    refreshBut = new JButton(new ImageIcon(this.getClass().getResource("/images/reloadIcon.png")));
    refreshBut.setVisible(false);
    refreshBut.setToolTipText("Refresh");
    refreshBut.setForeground(new Color(20, 88, 49));
    refreshBut.addActionListener(this);
    backBut = new JButton(new ImageIcon(this.getClass().getResource("/images/backIcon.png")));
    backBut.setVisible(false);
    backBut.setToolTipText("Back");
    backBut.setForeground(new Color(20, 88, 49));
    backBut.addActionListener(this);
    deleteBut = new JButton(new ImageIcon(this.getClass().getResource("/images/trashIcon.png")));
    deleteBut.setToolTipText("Delete");
    deleteBut.setForeground(Color.red);
    deleteBut.setVisible(false);
    deleteBut.addActionListener(this);
    deleteBut.setBackground(Color.red);
    restoreBut = new JButton(new ImageIcon(this.getClass().getResource("/images/restoreIcon.png")));
    restoreBut.setToolTipText("Restore");
    restoreBut.setForeground(Color.blue);
    restoreBut.setVisible(false);
    restoreBut.addActionListener(this);
    toolBar.addSeparator(new Dimension(10, 5));
    toolBar.add(selectAllCB);
    toolBar.add(backBut);
    toolBar.add(refreshBut);
    toolBar.add(deleteBut);
    toolBar.add(restoreBut);
    add(toolBar, "North");
    JPanel centPan = new JPanel(new GridBagLayout());
    centPan.setBackground(new Color(52, 86, 70));
    JLabel label = new JLabel("Select A Category From Left Pane");
    label.setFont(new Font("arial", Font.BOLD, 35));
    label.setForeground(Color.yellow);
    centPan.add(label);
    contentPan = new JScrollPane(centPan);
    contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    add(contentPan, "Center");
    contentPan.repaint();

    db = new Database();
    //        inboxSet = db.getData("SELECT * FROM messages WHERE tag='inbox' ORDER BY msg_id
    // desc");
    //        sentmailSet = db.getData("SELECT * FROM messages WHERE tag='sentmail' ORDER BY msg_id
    // desc");
    //        draftSet = db.getData("SELECT * FROM messages WHERE tag='draft' ORDER BY msg_id
    // desc");
    //        outboxSet = db.getData("SELECT * FROM messages WHERE tag='outbox' ORDER BY msg_id
    // desc");
    //        trashSet = db.getData("SELECT * FROM messages,trash WHERE messages.tag='trash' and
    // messages.msg_id=trash.msg_id ORDER BY deleted_at desc");

  }
Ejemplo n.º 6
0
  public FavouritesView(Favourite favouritesModel) {
    super();

    // Set the favourites model, and register ourselves as an observer, so we can be notified
    // of any changes to the model.
    _favouritesModel = favouritesModel;
    _favouritesModel.addObserver(this);

    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    this.setBorder(BorderFactory.createTitledBorder("Favourites"));

    JPanel listPanel = new JPanel();
    listPanel.setLayout(new BoxLayout(listPanel, BoxLayout.Y_AXIS));
    listPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));

    _favouritesList = new JList();
    _favouritesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    _favouritesList.setLayoutOrientation(JList.VERTICAL);

    // Fetch initial favourited stations.
    updateList();

    _favouritesScroller = new JScrollPane(_favouritesList);
    _favouritesScroller.setHorizontalScrollBarPolicy(
        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    _favouritesScroller.setVerticalScrollBarPolicy(
        ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

    listPanel.add(_favouritesScroller);

    _remove = new JButton("Remove");
    _remove.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            // Remove the selected station from the user's favourites.
            Station station = (Station) _favouritesList.getSelectedValue();
            if (station != null) {
              _favouritesModel.removeStation(station);
            }
          }
        });

    _select = new JButton("Select");
    _select.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            // Display the selected favourite.
            if (_favouritesList.getSelectedValue() != null)
              _favouritesModel.setCurrentStation((Station) _favouritesList.getSelectedValue());
          }
        });

    JPanel buttonPanel = new JPanel();
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    buttonPanel.setMaximumSize(new Dimension(Short.MAX_VALUE, 25));

    buttonPanel.add(_select);
    buttonPanel.add(_remove);

    this.add(listPanel);
    this.add(buttonPanel);
  }