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 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(); } }
public DialogPanel receiveIncomingMessage( Message message, BufferedImage myPhoto, BufferedImage friendPhoto, Mode mode) { if (mode == Mode.HOME_PANEL) { homeButton.setIcon(newDialogButIcon); PopUpMenu.displayMessage("You have new message from " + message.getNickname_From()); homeButton.addMouseListener( new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { homeButton.setIcon(newDialogButIconEntered); } @Override public void mouseExited(MouseEvent e) { homeButton.setIcon(newDialogButIcon); } }); } for (int i = 0; i < dialogTabArrayList.size(); i++) { if (message.getNickname_From().equals(dialogTabArrayList.get(i).getNickButton().getText())) { if (dialogTabArrayList.get(i).equals(currentDialogTab)) { dialogPanelArrayList.get(i).showIncomingMessage(message); } else { dialogPanelArrayList.get(i).showIncomingMessage(message); dialogTabArrayList.get(i).getNewMessageLabel().setVisible(true); } return null; } } final DialogTab dialogTab = new DialogTab(message.getNickname_From()); dialogTab.setBorder(new LineBorder(Color.WHITE)); dialogTabArrayList.add(dialogTab); dialogTab.getNewMessageLabel().setVisible(true); final DialogPanel dialogPanel = new DialogPanel(); try { dialogPanel.updateInfo(myPhoto, friendPhoto); } catch (IOException e) { e.printStackTrace(); } dialogPanelArrayList.add(dialogPanel); 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; if (!(currentDialogPanel == null)) currentDialogPanel.setVisible(false); currentDialogPanel = dialogPanel; currentDialogPanel.setBounds(0, 84, 960, 1000); bigPanel.add(currentDialogPanel); currentDialogPanel.setVisible(true); repaintDialogTabsPanel(); repaint(); revalidate(); } }); dialogPanel.showIncomingMessage(message); noConversationsPanel.setVisible(false); return dialogPanel; }
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; }