Hasta ahora no he encontrado ayuda que me acerque a mi objetivo
Para la próxima en lo posible coloca código hecho https://docs.oracle.com/javase/tutorial/uiswing/components/editorpane.htmlhttps://docs.oracle.com/javase/tutorial/displayCode.html?code=https://docs.oracle.com/javase/tutorial/uiswing/examples/components/TextSamplerDemoProject/src/components/TextSamplerDemo.javaimport javax.swing.*;
import javax.swing.text.*;
import java.awt.*;
public class TestForo
extends JPanel {
private static final String newline
= "\n";
public TestForo() {
scrollPane.
setVerticalScrollBarPolicy(JScrollPane.
VERTICAL_SCROLLBAR_ALWAYS); scrollPane.
setPreferredSize(new Dimension(10,
10)); scrollPane.
setMinimumSize(new Dimension(10 ,
10));
add(scrollPane);
}
{ "JenselGe hola soy java, espero que ejecutes esto XD, ", //regular
"another ", //italic
"styled ", //bold
"text ", //small
"component, ", //large
"which supports embedded components..." + newline,//regular
"y no pondre lloronas XD " + newline, //button
"...and embedded icons..." + newline, //regular
newline + "JTextPane is a subclass of JEditorPane that " +
"uses a StyledEditorKit and StyledDocument, and provides " +
"cover methods for interacting with those objects."
};
String[] initStyles
= { "regular",
"italic",
"bold",
"small",
"large",
"regular",
"regular",
"regular",
"bold"};
addStylesToDocument(doc);
try {
for (int i=0; i < initString.length; i++) {
doc.insertString(doc.getLength(), initString[i], doc.getStyle(initStyles[i]));
}
System.
err.
println("Couldn't insert initial text into text pane."); }
return textPane;
}
//Initialize some styles.
Style regular
= doc.
addStyle("regular", def
);
Style s
= doc.
addStyle("italic", regular
);
s = doc.addStyle("bold", regular);
s = doc.addStyle("small", regular);
s = doc.addStyle("large", regular);
s = doc.addStyle("bold" , regular);
}
public static void main
(String ...
agrea ) { jFrame.
setDefaultCloseOperation(JFrame.
EXIT_ON_CLOSE); jFrame.add(new TestForo());
jFrame.pack();
jFrame.setLocationRelativeTo(null);
jFrame.setVisible(true);
}).start();
}
}