Example #1
0
  public boolean closeDialog(DialogTab dialogTab) {
    for (int i = 0; i < dialogTabArrayList.size(); i++) {
      if (dialogTabArrayList.get(i).equals(dialogTab)) {
        dialogPanelArrayList.remove(i);
        dialogTabArrayList.remove(i);
        if (!(currentDialogPanel == null)) currentDialogPanel.setVisible(false);
        if (dialogTabArrayList.size() == 0) {
          dialogTabsPanel.setVisible(false);
          currentDialogTab = null;
          currentDialogPanel = null;
          repaint();
          revalidate();
          return true;
        }

        if ((dialogTab.equals(currentDialogTab))) {
          if (i > 0) {
            currentDialogPanel = dialogPanelArrayList.get(i - 1);
            currentDialogTab = dialogTabArrayList.get(i - 1);
          } else {
            currentDialogPanel = dialogPanelArrayList.get(i);
            currentDialogTab = dialogTabArrayList.get(i);
          }
        }

        if (!(currentDialogPanel == null)) {
          currentDialogTab.setBorder(new LineBorder(Color.RED));
          currentDialogPanel.setBounds(0, 84, 960, 1000);
          bigPanel.add(currentDialogPanel);
          currentDialogPanel.setVisible(true);
        }

        dialogTabsPanel.setVisible(false);
        if (dialogTabArrayList.size() > 0) repaintDialogTabsPanel();
        bigPanel.repaint();
        bigPanel.revalidate();
        break;
      }
    }
    return false;
  }
Example #2
0
  public void changeMode(Mode mode) {
    if (mode == Mode.DIALOG) {
      boolean newMessages = false;
      for (int i = 0; i < dialogTabArrayList.size(); i++) {
        if (dialogTabArrayList.get(i).getNewMessageLabel().isVisible()) {
          newMessages = true;
        }
      }
      if (newMessages) {
        homeButton.setIcon(newDialogButIcon);
      } else {
        homeButton.setIcon(dialogButIcon);
      }
      final boolean finalNewMessages = newMessages;
      homeButton.addMouseListener(
          new MouseAdapter() {
            @Override
            public void mouseEntered(MouseEvent e) {
              if (finalNewMessages) {
                homeButton.setIcon(newDialogButIconEntered);
              } else {
                homeButton.setIcon(dialogButIconEntered);
              }
            }

            @Override
            public void mouseExited(MouseEvent e) {
              if (finalNewMessages) {
                homeButton.setIcon(newDialogButIcon);
              } else {
                homeButton.setIcon(dialogButIcon);
              }
            }
          });

      if (!(currentDialogTab == null)) currentDialogPanel.setVisible(false);
      homePanel.setVisible(true);
      friendPanelButton.setVisible(false);
      dialogTabsPanel.setVisible(false);
      isFriendPanelOpened = false;
      noConversationsPanel.setVisible(false);
      friendPanelMode();
    } else if (mode == Mode.HOME_PANEL) {

      homeButton.setIcon(homeButIcon);
      homeButton.addMouseListener(
          new MouseAdapter() {
            @Override
            public void mouseEntered(MouseEvent e) {
              homeButton.setIcon(homeButIconEntered);
            }

            @Override
            public void mouseExited(MouseEvent e) {
              homeButton.setIcon(homeButIcon);
            }
          });

      friendPanelButton.setVisible(true);
      homePanel.setVisible(false);
      if (dialogTabArrayList.size() > 0) {
        dialogTabsPanel.setVisible(true);
      } else {
        noConversationsPanel.setVisible(true);
      }
      if (!(currentDialogPanel == null)) {
        currentDialogPanel.setVisible(true);
      }
      friendPanelButton.setVisible(true);
      repaint();
    }
  }
Example #3
0
  public boolean startNewDialog(
      BufferedImage myPhoto, BufferedImage friendPhoto, String friendNick) {
    for (int i = 0; i < dialogTabArrayList.size(); i++) {
      if (dialogTabArrayList.get(i).getNickButton().getText().equals(friendNick)) {
        if (!(currentDialogPanel == null)) {
          currentDialogPanel.setVisible(false);
          currentDialogTab.setBorder(new LineBorder(Color.WHITE));
        }
        currentDialogPanel = dialogPanelArrayList.get(i);
        currentDialogTab = dialogTabArrayList.get(i);
        currentDialogTab.setBorder(new LineBorder(Color.RED));
        currentDialogTab.getNewMessageLabel().setVisible(false);
        currentDialogPanel.setBounds(0, 84, 960, 1000);
        bigPanel.add(currentDialogPanel);
        currentDialogPanel.setVisible(true);
        repaint();
        revalidate();
        return false;
      }
    }

    final DialogTab dialogTab = new DialogTab(friendNick);
    currentDialogTab = dialogTab;

    dialogTab.setBorder(new LineBorder(Color.RED));
    dialogTabArrayList.add(dialogTab);
    final DialogPanel dialogPanel = new DialogPanel();
    try {
      dialogPanel.updateInfo(myPhoto, friendPhoto);
    } catch (IOException e) {
      e.printStackTrace();
    }
    dialogPanelArrayList.add(dialogPanel);

    for (int i = 0; i < dialogTabArrayList.size() - 1; i++) {
      dialogTabArrayList.get(i).setBorder(new LineBorder(Color.WHITE));
    }

    if (!(currentDialogPanel == null)) currentDialogPanel.setVisible(false);
    currentDialogPanel = dialogPanel;
    currentDialogPanel.setBounds(0, 84, 960, 1000);
    bigPanel.add(currentDialogPanel);
    repaintDialogTabsPanel();
    repaint();
    revalidate();

    dialogTab
        .getNickButton()
        .addActionListener(
            new AbstractAction() {
              @Override
              public void actionPerformed(ActionEvent e) {
                for (int i = 0; i < dialogTabArrayList.size(); i++) {
                  dialogTabArrayList.get(i).setBorder(new LineBorder(Color.WHITE));
                }

                dialogTab.setBorder(new LineBorder(Color.RED));

                dialogTab.getNewMessageLabel().setVisible(false);

                currentDialogTab = dialogTab;

                currentDialogPanel.setVisible(false);
                currentDialogPanel = dialogPanel;
                currentDialogPanel.setBounds(0, 84, 960, 1000);
                bigPanel.add(currentDialogPanel);
                currentDialogPanel.setVisible(true);
                repaintDialogTabsPanel();
                repaint();
                revalidate();
              }
            });

    noConversationsPanel.setVisible(false);

    return true;
  }