Пример #1
2
  /** Inicializace základních komponent okna */
  private void init() {

    krokLabel = new JLabel("Synchronizace s web aplikací");
    Font pismo = new Font("Arial", Font.BOLD, 14);
    krokLabel.setFont(pismo);
    NacitaciOkno.add(krokLabel);
    krokLabel.setBounds(90, 10, 250, 20);

    startButton = new JButton("Načíst");
    startButton.setActionCommand("start");
    startButton.setBounds(250, 110, 120, 25);
    startButton.addActionListener(new Start());

    progressBar = new JProgressBar(0, 100);
    progressBar.setBounds(20, 60, 350, 25);
    progressBar.setValue(0);

    progressBar.setStringPainted(true);

    taskOutput = new JTextArea(5, 20);
    taskOutput.setMargin(new Insets(5, 5, 5, 5));
    taskOutput.setEditable(false);

    NacitaciOkno.add(startButton);
    NacitaciOkno.add(progressBar);

    NacitaciOkno.setVisible(true);

    vybratButton = new JButton("Otevřít");
    NacitaciOkno.add(vybratButton);
    vybratButton.setBounds(20, 110, 120, 25);
    vybratButton.addActionListener(new Zpet());
  }
  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
  }
Пример #3
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");

  }
Пример #4
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);
  }
Пример #5
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);
  }