Beispiel #1
0
  public void updateShowHideCalendars(ArrayList<User> users) {
    GroupLayout layout = new GroupLayout(showHideCalendarsPanel);
    showHideCalendarsPanel.setLayout(layout);

    labels = new ArrayList<JLabel>(); // emptying the list
    for (int i = 0; i < users.size(); i++) {
      JLabel temp = new JLabel();
      temp.addMouseListener(mouseTempListener(temp));

      temp.setText(users.get(i).getName());
      temp.setBackground(Color.white);

      temp.setOpaque(true);
      temp.setIcon(tick);
      temp.setIconTextGap(10);
      temp.setBorder(BorderFactory.createEmptyBorder(3, 10, 3, 10));
      labels.add(temp);
    }

    ParallelGroup showHideCalendarsHorizontalGroup =
        layout.createParallelGroup(GroupLayout.Alignment.LEADING);
    for (int i = 0; i < labels.size(); i++) {
      showHideCalendarsHorizontalGroup.addComponent(
          labels.get(i), GroupLayout.DEFAULT_SIZE, 335, Short.MAX_VALUE);
    }

    SequentialGroup showHideCalendarsVerticalGroup = layout.createSequentialGroup();
    for (int i = 0; i < labels.size(); i++) {
      showHideCalendarsVerticalGroup.addComponent(
          labels.get(i), GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE);
    }

    layout.setHorizontalGroup(showHideCalendarsHorizontalGroup);
    layout.setVerticalGroup(showHideCalendarsVerticalGroup);
  }
Beispiel #2
0
  public void updateAgenda(ArrayList<Event> eventsList) {
    GroupLayout layout = new GroupLayout(agendaPanel);
    agendaPanel.setLayout(layout);

    System.out.println("number of agendas: " + eventsList.size());
    eventLabels = new ArrayList<JLabel>();
    // Collections.sort(eventsList, new TimeComparator()); //Sorts the list based on when the event
    // is
    for (int i = 0; i < eventsList.size(); i++) {
      JLabel temp = new JLabel();
      temp.setText(
          eventsList.get(i).getTitle() + " - " + eventsList.get(i).getStartTime().toGMTString());
      temp.setOpaque(true);
      if (i % 2 == 0) {
        temp.setBackground(Color.white);
      } else {
        temp.setBackground(new Color(245, 245, 245));
      }
      temp.setBorder(BorderFactory.createEmptyBorder(3, 10, 3, 10));
      eventLabels.add(temp);
    }

    ParallelGroup agendaHorizontalGroup = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
    for (int i = 0; i < eventLabels.size(); i++) {
      agendaHorizontalGroup.addComponent(
          eventLabels.get(i), GroupLayout.DEFAULT_SIZE, 335, Short.MAX_VALUE);
    }

    SequentialGroup agendaVerticalGroup = layout.createSequentialGroup();
    for (int i = 0; i < eventLabels.size(); i++) {
      agendaVerticalGroup.addComponent(
          eventLabels.get(i), GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE);
    }

    layout.setHorizontalGroup(agendaHorizontalGroup);
    layout.setVerticalGroup(agendaVerticalGroup);
  }
  private void initComponents() {
    entry = new JTextField();
    textArea = new JTextArea();
    status = new JLabel();
    jLabel1 = new JLabel();

    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setTitle("TextFieldDemo");

    textArea.setColumns(20);
    textArea.setLineWrap(true);
    textArea.setRows(5);
    textArea.setWrapStyleWord(true);
    textArea.setEditable(false);
    jScrollPane1 = new JScrollPane(textArea);

    jLabel1.setText("Enter text to search:");

    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);

    ParallelGroup hGroup = layout.createParallelGroup(GroupLayout.Alignment.LEADING);

    SequentialGroup h1 = layout.createSequentialGroup();
    ParallelGroup h2 = layout.createParallelGroup(GroupLayout.Alignment.TRAILING);

    h1.addContainerGap();

    h2.addComponent(
        jScrollPane1,
        GroupLayout.Alignment.LEADING,
        GroupLayout.DEFAULT_SIZE,
        450,
        Short.MAX_VALUE);
    h2.addComponent(
        status, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE);

    SequentialGroup h3 = layout.createSequentialGroup();
    h3.addComponent(jLabel1);
    h3.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED);
    h3.addComponent(entry, GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE);

    h2.addGroup(h3);
    h1.addGroup(h2);

    h1.addContainerGap();

    hGroup.addGroup(GroupLayout.Alignment.TRAILING, h1);
    layout.setHorizontalGroup(hGroup);

    ParallelGroup vGroup = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
    SequentialGroup v1 = layout.createSequentialGroup();
    v1.addContainerGap();
    ParallelGroup v2 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    v2.addComponent(jLabel1);
    v2.addComponent(
        entry, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE);
    v1.addGroup(v2);
    v1.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED);
    v1.addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE);

    v1.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED);
    v1.addComponent(status);
    v1.addContainerGap();

    vGroup.addGroup(v1);
    layout.setVerticalGroup(vGroup);
    pack();
  }