1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
import java.awt.BorderLayout;
import java.awt.Container;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.WindowConstants;
import jsyntaxpane.DefaultSyntaxKit;
public class SyntaxTester {
public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new SyntaxTester().setVisible(true);
}
});
}
public TestIssue47() {
JFrame f = new JFrame(TestIssue47.class.getName());
final Container c = f.getContentPane();
c.setLayout(new BorderLayout());
DefaultSyntaxKit.initKit();
final JEditorPane codeEditor = new JEditorPane();
JScrollPane scrPane = new JScrollPane(codeEditor);
c.add(scrPane, BorderLayout.CENTER);
c.doLayout();
codeEditor.setContentType("text/java");
codeEditor.setText("public static void main(String[] args) {\n}");
f.setSize(800, 600);
f.setVisible(true);
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
} |
Partager