/* * Test method for 'java.awt.TextArea.insert(String, int)' */ public void testInsert() { String text = "text"; area.setText(text); String str = "inserted text\n"; area.insert(str, 0); assertEquals(str + text, area.getText()); assertEquals(0, area.getRows()); assertEquals(0, area.getCaretPosition()); }
/* * Test method for 'java.awt.TextArea.replaceText(String, int, int)' */ @SuppressWarnings("deprecation") public void testReplaceText() { String text = "This is old text"; area.setText(text); String str = "new\n"; area.replaceText(str, 8, 12); assertEquals("This is new\ntext", area.getText()); assertEquals(0, area.getColumns()); assertEquals(0, area.getCaretPosition()); }
/* * Test method for 'java.awt.TextArea.insertText(String, int)' */ @SuppressWarnings("deprecation") public void testInsertText() { String text = "text"; area.setText(text); String str = "inserted text\n"; area.insertText(str, 0); assertEquals(str + text, area.getText()); assertEquals(0, area.getColumns()); assertEquals(0, area.getCaretPosition()); }
/* * Test method for 'java.awt.TextArea.append(String)' */ public void testAppend() { String text = "text"; area.setText(text); String str = "\nappended text"; area.append(str); assertEquals(text + str, area.getText()); assertEquals(0, area.getRows()); assertEquals(0, area.getCaretPosition()); }
/* * Test method for 'java.awt.TextArea.replaceRange(String, int, int)' */ public void testReplaceRange() { int start = 8; int end = 11; String text = "This is old text"; area.setText(text); String str = "brand new"; area.replaceRange(str, start, end); assertEquals("This is brand new text", area.getText()); assertEquals("", area.getSelectedText()); assertEquals(0, area.getRows()); assertEquals(0, area.getCaretPosition()); }
public void refreshPopupItems() { if (!showPopUp) { return; } macrosPopup.removeAll(); TextArea ta = OJ.editor.getTextArea(); String macros_text = ta.getText(); int caretPos = ta.getCaretPosition(); String menuStrings = UtilsOJ.extractFunctions(macros_text, caretPos); String[] lines = menuStrings.split("\n"); Font theFont = new java.awt.Font("MS Sans Serif", 0, 12); // NOI18N for (int jj = 0; jj < lines.length; jj++) { String line = lines[jj]; if (line.length() > 5) { int lineNo = Integer.parseInt(line.substring(0, 5).trim()); char kind = line.charAt(6); char caret = line.charAt(7); String title = line.substring(8, line.length()); Color color = new Color(0, 0, 255); if (kind == 'f') { color = new Color(0, 100, 0); title = " " + title; } if (kind == 'b') { color = new Color(200, 0, 80); title = " " + title; } JMenuItem thisItem = new javax.swing.JMenuItem(title); thisItem.setAlignmentX((float) lineNo / 1000000); thisItem.setForeground(color); if (caret == '*') { thisItem.setBackground(new Color(255, 255, 188)); } thisItem.setFont(theFont); macrosPopup.add(thisItem); thisItem.addActionListener(itemAction); } } }