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; }
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; }