/** * Disables/Enables history arrow buttons depending on whether the current page is the first, the * last page or a middle page. * * @param chatPanel the <tt>ChatPanel</tt> which has provoked the change. */ public void changeHistoryButtonsState(ChatPanel chatPanel) { ChatConversationPanel convPanel = chatPanel.getChatConversationPanel(); long firstMsgInHistory = chatPanel.getFirstHistoryMsgTimestamp().getTime(); long lastMsgInHistory = chatPanel.getLastHistoryMsgTimestamp().getTime(); Date firstMsgInPage = convPanel.getPageFirstMsgTimestamp(); Date lastMsgInPage = convPanel.getPageLastMsgTimestamp(); if (firstMsgInHistory == 0 || lastMsgInHistory == 0) { previousButton.setEnabled(false); nextButton.setEnabled(false); return; } previousButton.setEnabled(firstMsgInHistory < firstMsgInPage.getTime()); nextButton.setEnabled( (lastMsgInPage.getTime() > 0) && (lastMsgInHistory > lastMsgInPage.getTime())); }