DemoRootPane() { textArea = createTextArea(); setText("JavaExample.txt"); textArea.setSyntaxEditingStyle(SYNTAX_STYLE_JAVA); scrollPane = new RTextScrollPane(textArea, true); Gutter gutter = scrollPane.getGutter(); gutter.setBookmarkingEnabled(true); URL url = getClass().getResource("bookmark.png"); gutter.setBookmarkIcon(new ImageIcon(url)); getContentPane().add(scrollPane); ErrorStrip errorStrip = new ErrorStrip(textArea); //errorStrip.setBackground(java.awt.Color.blue); getContentPane().add(errorStrip, BorderLayout.LINE_END); setJMenuBar(createMenuBar()); }
@Test public void testGetBookmarkIcon() { RTextArea textArea = new RTextArea(PLAIN_TEXT); Gutter gutter = new Gutter(textArea); Assert.assertNull(gutter.getBookmarkIcon()); Icon icon = new TestIcon(); gutter.setBookmarkIcon(icon); Assert.assertTrue(icon == gutter.getBookmarkIcon()); }
@Test public void testSetBookmarkIcon() { RTextArea textArea = new RTextArea(PLAIN_TEXT); Gutter gutter = new Gutter(textArea); Assert.assertNull(gutter.getBookmarkIcon()); Icon icon = new TestIcon(); gutter.setBookmarkIcon(icon); Assert.assertTrue(icon == gutter.getBookmarkIcon()); }
@Test public void getBookmarks_SomeBookmarks() throws Exception { RTextArea textArea = new RTextArea(PLAIN_TEXT); Gutter gutter = new Gutter(textArea); gutter.setBookmarkingEnabled(true); gutter.setBookmarkIcon(new TestIcon()); Assert.assertTrue(gutter.toggleBookmark(1)); Assert.assertTrue(gutter.toggleBookmark(2)); Assert.assertEquals(2, gutter.getBookmarks().length); // Non-null }
@Test public void testToggleBookmark() throws Exception { RTextArea textArea = new RTextArea(PLAIN_TEXT); Gutter gutter = new Gutter(textArea); gutter.setBookmarkingEnabled(true); gutter.setBookmarkIcon(new TestIcon()); Assert.assertTrue(gutter.toggleBookmark(1)); Assert.assertFalse(gutter.toggleBookmark(1)); Assert.assertTrue(gutter.toggleBookmark(1)); }