Java Code Examples for javax.swing.JTextArea#setCaret()
The following examples show how to use
javax.swing.JTextArea#setCaret() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextualDocumentView.java From gate-core with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected void initGUI() { // textView = new JEditorPane(); // textView.setContentType("text/plain"); // textView.setEditorKit(new RawEditorKit()); textView = new JTextArea(); textView.setAutoscrolls(false); textView.setLineWrap(true); textView.setWrapStyleWord(true); // the selection is hidden when the focus is lost for some system // like Linux, so we make sure it stays // it is needed when doing a selection in the search textfield textView.setCaret(new PermanentSelectionCaret()); scroller = new JScrollPane(textView); textView.setText(document.getContent().toString()); textView.getDocument().addDocumentListener(swingDocListener); // display and put the caret at the beginning of the file SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { if(textView.modelToView(0) != null) { textView.scrollRectToVisible(textView.modelToView(0)); } textView.select(0, 0); textView.requestFocus(); } catch(BadLocationException e) { e.printStackTrace(); } } }); // contentPane = new JPanel(new BorderLayout()); // contentPane.add(scroller, BorderLayout.CENTER); // //get a pointer to the annotation list view used to display // //the highlighted annotations // Iterator horizViewsIter = owner.getHorizontalViews().iterator(); // while(annotationListView == null && horizViewsIter.hasNext()){ // DocumentView aView = (DocumentView)horizViewsIter.next(); // if(aView instanceof AnnotationListView) // annotationListView = (AnnotationListView)aView; // } highlightsMinder = new Timer(BLINK_DELAY, new UpdateHighlightsAction()); highlightsMinder.setInitialDelay(HIGHLIGHT_DELAY); highlightsMinder.setDelay(BLINK_DELAY); highlightsMinder.setRepeats(true); highlightsMinder.setCoalesce(true); highlightsMinder.start(); // blinker = new Timer(this.getClass().getCanonicalName() + // "_blink_timer", // true); // final BlinkAction blinkAction = new BlinkAction(); // blinker.scheduleAtFixedRate(new TimerTask(){ // public void run() { // blinkAction.actionPerformed(null); // } // }, 0, BLINK_DELAY); initListeners(); }
Example 2
Source File: StartupConfigurator.java From visualvm with GNU General Public License v2.0 | 4 votes |
private JPanel createStepsPanel() { JPanel steps = new JPanel(new VerticalLayout(false)); steps.setBorder(BorderFactory.createEmptyBorder(5, 13, 15, 5)); steps.setOpaque(false); start1 = new JTextArea(); start1.setLineWrap(true); start1.setWrapStyleWord(true); start1.setEditable(false); start1.setFocusable(false); start1.setOpaque(false); if (UISupport.isNimbusLookAndFeel()) start1.setBackground(new Color(0, 0, 0, 0)); start1.setCaret(new NullCaret()); start1.setBorder(BorderFactory.createEmptyBorder()); steps.add(start1); final JPanel arg = new JPanel(new BorderLayout(5, 0)); arg.setOpaque(false); TextAreaComponent paramA = createTextArea(1); param = paramA.getTextArea(); updateParam(); arg.add(paramA, BorderLayout.CENTER); JButton link = new JButton(Bundle.BTN_Clipboard()) { protected void fireActionPerformed(ActionEvent e) { RequestProcessor.getDefault().post(new Runnable() { public void run() { StringSelection s = new StringSelection(param.getText()); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(s, s); Dialogs.show(Dialogs.info(Bundle.CAP_Clipboard(), Bundle.MSG_Clipboard())); } }); } }; arg.add(link, BorderLayout.EAST); steps.add(createVerticalSpace(8)); steps.add(arg); steps.add(createVerticalSpace(8)); String user = System.getProperty("user.name"); // NOI18N if (user != null) user = Bundle.STR_User(user); else user = Bundle.STR_CurrentUser(); start2 = new JTextArea(Bundle.HINT_StartApp(user)); start2.setLineWrap(true); start2.setWrapStyleWord(true); start2.setEditable(false); start2.setFocusable(false); start2.setOpaque(false); if (UISupport.isNimbusLookAndFeel()) start2.setBackground(new Color(0, 0, 0, 0)); start2.setCaret(new NullCaret()); start2.setBorder(BorderFactory.createEmptyBorder()); steps.add(start2); return steps; }