@Override
                public void actionPerformed(ActionEvent e) {
                    ChannelPanel channel = (ChannelPanel) tabbedPane.getSelectedComponent();
                    StyledDocument doc = channel.chatPane.getStyledDocument();
                    DefaultHighlighter.DefaultHighlightPainter p = new DefaultHighlighter.DefaultHighlightPainter(highlightColor);
                    DefaultHighlighter highlighter = (DefaultHighlighter) channel.chatPane.getHighlighter();
                    highlighter.setDrawsLayeredHighlights(false);
                    String searchString = field.getText();


                    if (highlightAll.isSelected()) {
                        highlightAll(searchString);
                        return;
                    }


                    String s = "";
                    try {
                        s = doc.getText(0, doc.getLength());
                    } catch (BadLocationException ex) {
                        Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
                    }


                    int location;
                    if (matchCase.isSelected()) {
                        if (channel.lastSearchIndex == -1) location = s.indexOf(searchString);
                        else location = s.indexOf(searchString, channel.lastSearchIndex + searchString.length());
                    } else {
                        if (channel.lastSearchIndex == -1) location = StringUtils.indexOfIgnoreCase(s, searchString);
                        else
                            location = StringUtils.indexOfIgnoreCase(s, searchString, channel.lastSearchIndex + searchString.length());
                    }

                    if (location != -1) {
                        try {
                            removeHighlights();
                            highlighter.addHighlight(location, location + searchString.length(), p);
                            channel.lastSearchIndex = location;
                            DefaultCaret caret = (DefaultCaret) channel.chatPane.getCaret();
                            caret.setDot(location);
                        } catch (BadLocationException ex) {
                            Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
                }