zeilenumbruch in TextArea

Status
Nicht offen für weitere Antworten.

Shai

Aktives Mitglied
hi wie kann ich denn einen zeilenumbruch machen?

Code:
JTextArea text = new JTextArea();
		    text.setText("TFIDFInstanceExtraction extracts the most important instances with<br> respect to a given domain (e.g. OWL for the domain of Semantic Web). The relevance of each instance is determined by computing its average TF * IDF value with respect to the whole document collection.");
		    text.setPreferredSize(new Dimension(100,60));
		    
		    JScrollPane informationScrollPane = new JScrollPane(text);

so gehts nicht..
 
man kann z.b. den Text von JLabel per HTML gestalten, in dem Zusammenhang hast du wahrscheinlich das "br" gesehen. Beispiel:
Java:
import java.awt.Color;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class XXX{

    public static void main(String[] args){
        new XXX();}


    private JFrame window = new JFrame();
    private JPanel panel = new JPanel();

    public XXX(){
        window.setBounds(100,100,200,150);
        window.add(panel);

		JLabel label = new JLabel("<html><big>Hallo<br>Welt!</big></html>");
		panel.add(label);

        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                window.setVisible(true);
            }
        });

    }


}
 
Für HTML kannst auch JEditorPane verwenden!
Java:
JEditorPane editorPane = new JEditorPane();
editorPane.setContentType("text/html");
editorPane.setText("<big>Hallo</big><br>Welt!");
JScrollPane informationScrollPane = new JScrollPane(editorPane);
 
Status
Nicht offen für weitere Antworten.

Neue Themen


Zurück
Oben