Ability to view text in each class - java

Recently, I program for the Android platform. I have a question about the text.
Is there any way to display the text without using the XML?
I also want the text to be able to show in each class.

If you're asking if you can replace the text of anything programatically, yes you can. Usually, you have a setText method you can use for that. I'd advise you to read the tutorial and the javadoc to know more about this.

Related

Format an editable textarea

At the moment I try to find a method to create a TextArea that I can edit and simply (without cheating) apply syntax highlighting to. Is that possible without the need of a custom Component? I already managed to format a text using a JEditorPane, but I am not sure how to implement that the text is dynamicly highlighted... And that efficiently. Is that possibly without an enormous amount of coding?
You can't use a JTextArea since it does not support text attributes.
Instead you can use a JTextPane. Read the section from the Swing tutorial on Text Component Features for more information and examples.

Code/text folding in SWING

I'm looking for a way to provide 'text folding' capabilities to a swing JTextArea or JTextPane
More specifically, I want to add a block of data in a text component and I want the component to display only some header line. Then the user can unfold the block by clicking some icon. This is just like the code folding feature in most IDE.
I've found ->some sample code<- after some thorough search, but the mechanisms used here are quite obscure to me and it stops working when I try to remove text from the document.
Maybe using XML as input could be a lead ?
This one how to add collapsible area
http://java-sl.com/collapse_area.html
This one how to represent XML
http://java-sl.com/xml_editor_kit.html
I would start by looking at the NetBeans API: http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-editor-fold/overview-summary.html
If you were to do it yourself, you'd need to provide a Document implementation that makes the JTextComponent think that pieces are being added or removed, then attach click events that tell the document to update itself. A lot of work.
Visually, it may also be better to use JEditorPane, but that's probably more work.

Using styledText in SWT application

I have a simple question really: SWT documentation says that if you're using styledText, you either implements its API or you implement LineStyleListener.
So, If I do use LineStyleListener, how can I still control the representation of specific characters in the editor widget? It seems that implementing LineStyleListener only provides coloring of the whole line at a time.
Thanks
With the LineStyleListener you can still add styles for single characters by modifying the provided StyleRange array. It is called LineStyleListener only because you get the text by lines.
For explanations how to use this, see here or here.

Syntax highlight in java for android

I want to build an notepad-style application on android that will have syntax highlighting. But when I search around the web, I find the syntax highlighting can be done only through use of an awt class. How could I syntax highlight in maybe a custom EditText or TextView view? I know that the release of a syntax highlighter is sort of anticipated, so I want to add my syntax highlighter on the market.
Take a look at the android.text namespace. Specifically, you'll want either an Editable or a Spannable as your text format instead of strings. The android.text.style namespace has the various kinds of markup you can apply to spans of text.
If someone know Russian, you can read my article about this topic here. Anyway there picture and code snippets that can give you a direction. If you want to check out result, it can be found here

in java language, in order to make a text editor like textmate, what widget should i use

i want to write a text editor in java. i want it have a snippet feature similar to textmate. now i have no idea what to use as the main editor area. should i use some widget in swing?
great thanks.
Since a large part of the core added value of an editor such as textmate is the text editing view, if you were making a text editor you probably should implement the view from scratch ( JComponent and override drawing and event handling ).
If instead you want a feature rich text editing component for another project, then there's a Java binding http://sourceforge.net/projects/jintilla/ for the Scintilla editor, which is quite nice ( SciTE or Notepad++ use Scintilla ).
I think you are going to want to use JTextArea, and probably wrap it in a JScrollPane. You may want to look at JEdit, it is a text editor written in java, you can view the source and get some ideas from how they are doing things. The tricky part is going to be handling the formatting of snippet you are trying to create. JEdit has plugins for different languages, so I would definitely check that out for some ideas on how they handle things.
If I understand what you're wanting to do, you could use a JTextArea to accomplish this. I have a multithreaded text editor application I made that uses a JTextArea as the main editing area. It's nothing fancy but it was fun to make.

Categories

Resources