Exemplo n.º 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);
  }
  private JScrollPane makeTab(String type) {
    JPanel panel = new JPanel();
    GroupLayout layout = new GroupLayout(panel);
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);
    panel.setLayout(layout);

    JScrollPane scroll =
        new JScrollPane(
            panel,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scroll.setLayout(new ScrollPaneLayout());

    SequentialGroup sg = layout.createSequentialGroup();
    ParallelGroup pg = layout.createParallelGroup();

    String editString = "Edit " + type + "s";
    JButton editType = new JButton(editString);

    editType.addActionListener(new EditListener(myWorldManager, type, this));

    sg.addComponent(editType);
    pg.addComponent(editType);

    List<String> tileNames = myWorldManager.getNames(type);
    for (int n = 0; n < tileNames.size(); n++) {
      GameObjectPanel gop =
          new GameObjectPanel(type, myWorldManager.getImage(type, n), tileNames.get(n), this);
      panel.add(gop);
      sg.addComponent(gop, 50, 50, 50);
      pg.addComponent(gop, 170, 170, 170);
    }
    layout.setVerticalGroup(sg);
    layout.setHorizontalGroup(pg);
    panel.revalidate();
    panel.repaint();
    scroll.setMaximumSize(new Dimension(200, 500));
    return scroll;
  }
Exemplo n.º 3
0
  private void initLayout() { // {{{
    layout = new javax.swing.GroupLayout(listPanel);

    super.setLayout(blayout);
    layout.setHonorsVisibility(true);
    // layout.setAutoCreateContainerGaps(true);
    layout.setAutoCreateGaps(true);

    ParallelGroup pg = layout.createParallelGroup(Alignment.LEADING);
    SequentialGroup sg = layout.createSequentialGroup();
    pg = pg.addGroup(sg);
    // add components to this one.
    vgroup = layout.createParallelGroup(Alignment.LEADING);
    sg.addGroup(vgroup);
    layout.setHorizontalGroup(pg);

    // Add out components to this one.
    hgroup = layout.createSequentialGroup();
    ParallelGroup pg1 = layout.createParallelGroup(Alignment.LEADING).addGroup(hgroup);
    layout.setVerticalGroup(pg1);
    // Add the listPanel to our layout
    listPanel.setLayout(layout);
    add(userListPane, BorderLayout.CENTER);
    setupToolBar();
    add(toolbar, BorderLayout.NORTH);
    btnNext.setEnabled(false);
    btnPrev.setEnabled(false);

    userListPane.setHorizontalScrollBarPolicy(
        javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    userListPane.setVerticalScrollBarPolicy(
        javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    userListPane.setAutoscrolls(true);
    userListPane.setName("userListPane"); // NOI18N
    userListPane.setViewportView(listPanel);
    javax.swing.JScrollBar bar = userListPane.getVerticalScrollBar();
    bar.setUnitIncrement(50);
    TwitzMainView.fixJScrollPaneBarsSize(userListPane);
  } // }}}
Exemplo n.º 4
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();
  }
  private void initComponents() {
    // Start with indeterminate
    progressBar.setIndeterminate(false);

    // the text fields are not editable
    authUrlText.setEditable(false);
    repoUrlText.setEditable(false);
    stackStatusText.setEditable(false);
    statusTable.setEnabled(false);
    totalText.setEditable(false);
    // seupt the layout
    GroupLayout layout = new GroupLayout(this);
    this.setLayout(layout);
    this.setBorder(border);
    // Use default gaps
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);
    // Horizontal
    ParallelGroup h1 = layout.createParallelGroup(GroupLayout.Alignment.TRAILING);
    h1.addComponent(authStaticLabel);
    h1.addComponent(repoStaticLabel);
    h1.addComponent(stackStatusLabel);
    h1.addComponent(totalLabel);
    ParallelGroup h2 = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
    h2.addComponent(authUrlText);
    h2.addComponent(repoUrlText);
    h2.addComponent(stackStatusText);
    h2.addComponent(totalText);
    ParallelGroup h3 = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
    h3.addComponent(changeStatus);
    SequentialGroup hSequence = layout.createSequentialGroup();
    hSequence.addGroup(h1);
    hSequence.addGroup(h2);
    hSequence.addGroup(h3);

    ParallelGroup h4 = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
    h4.addComponent(progressLabel);
    h4.addComponent(progressBar);
    h4.addComponent(tableScrollPane);

    ParallelGroup hOuter = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
    hOuter.addGroup(hSequence);
    hOuter.addGroup(h4);

    // Vertical
    ParallelGroup v1 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    v1.addComponent(authStaticLabel);
    v1.addComponent(authUrlText);
    ParallelGroup v2 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    v2.addComponent(repoStaticLabel);
    v2.addComponent(repoUrlText);
    ParallelGroup v3 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    v3.addComponent(stackStatusLabel);
    v3.addComponent(stackStatusText);
    v3.addComponent(changeStatus);
    ParallelGroup v4 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    v4.addComponent(progressLabel);
    ParallelGroup v5 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    v5.addComponent(progressBar);
    ParallelGroup v6 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    v6.addComponent(tableScrollPane);
    ParallelGroup v7 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    v7.addComponent(totalLabel);
    v7.addComponent(totalText);

    SequentialGroup vSequence = layout.createSequentialGroup();
    vSequence.addGroup(v1);
    vSequence.addGroup(v2);
    vSequence.addGroup(v3);
    vSequence.addGroup(v4);
    vSequence.addGroup(v5);
    vSequence.addGroup(v6);
    vSequence.addGroup(v7);

    layout.setHorizontalGroup(hOuter);
    layout.setVerticalGroup(vSequence);

    setPreferredSize(new Dimension(300, 400));
  }
Exemplo n.º 7
0
 public void addPanel(Component comp) // {{{
     {
   vgroup.addComponent(comp, 0, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE);
   hgroup.addComponent(comp, 0, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE);
 } // }}}