Esempio n. 1
0
  public void showDialog(JComponent dialog) {
    closeDialog();

    JRootPane rootPane = SwingUtilities.getRootPane(mainPanel);
    if (rootPane == null) {
      log.severe("could not find root pane for viewer to show dialog " + dialog);
    } else {
      JLayeredPane layeredPane = rootPane.getLayeredPane();
      Dimension d = dialog.getPreferredSize();
      if (dialogPanel == null) {
        dialogPanel = new DialogPanel(this, new BorderLayout());
      }
      Insets insets = dialogPanel.getInsets();
      int width = viewerPanel.getWidth() - insets.left - insets.right;
      int height = viewerPanel.getHeight() - insets.top - insets.bottom;
      if (d.width > width) {
        d.width = width;
      }
      if (d.height > height) {
        d.height = height;
      }
      dialogPanel.add(dialog, BorderLayout.CENTER);

      dialogPanel.setBounds(
          ((width - d.width) >> 1) + insets.left,
          ((height - d.height) >> 1) + insets.top,
          d.width + insets.left + insets.right,
          d.height + insets.top + insets.bottom);
      dialog.setVisible(true);
      layeredPane.add(dialogPanel, DIALOG_LAYER);
      currentDialog = dialog;
      mainPanel.repaint();
    }
  }
Esempio n. 2
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;
  }
Esempio n. 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;
  }