Open GoogleCodeExporter opened 9 years ago
Sorry, had a few unused imports in there... here it is again:
import groovy.swing.SwingBuilder
def swing = new SwingBuilder()
jsyntaxpane.DefaultSyntaxKit.initKit();
swing.edt{
frame( title:'Test', pack:true, show:true ){
panel(){
scrollPane( preferredSize:[1000, 400], maximumSize:[1000, 450] ){
editorPane( contentType: ("text/groovy"), text:"println \"Hello\"")
}
}
}
}
Original comment by FGregu...@gmail.com
on 9 Sep 2011 at 9:46
Found a workaround. It looks like it just doesn't like Groovy's dynamic
constructors. For example, this does not work:
import java.awt.Dimension
import javax.swing.JEditorPane
import javax.swing.JFrame
import javax.swing.JPanel
import javax.swing.JScrollPane
jsyntaxpane.DefaultSyntaxKit.initKit();
def frame = new JFrame()
frame.title = "Test"
def panel = new JPanel()
def editor = new JEditorPane(contentType:"text/groovy")
def scPane = new JScrollPane(editor)
panel.add(scPane)
frame.add(panel)
scPane.setPreferredSize(new Dimension(1000,400))
frame.pack()
frame.show()
But this does work:
import java.awt.Dimension
import javax.swing.JEditorPane
import javax.swing.JFrame
import javax.swing.JPanel
import javax.swing.JScrollPane
jsyntaxpane.DefaultSyntaxKit.initKit();
def frame = new JFrame()
frame.title = "Test"
def panel = new JPanel()
def editor = new JEditorPane()
def scPane = new JScrollPane(editor)
editor.setContentType("text/groovy")
panel.add(scPane)
frame.add(panel)
scPane.setPreferredSize(new Dimension(1000,400))
frame.pack()
frame.show()
So to go back to my example, the workaround would look something like this:
import groovy.swing.SwingBuilder
def swing = new SwingBuilder()
jsyntaxpane.DefaultSyntaxKit.initKit();
swing.edt{
frame( title:'Test', pack:true, show:true ){
panel(){
scrollPane( preferredSize:[1000, 400], maximumSize:[1000, 450] ){
editorPane( id:'ePane', text:"println \"Hello\"")
swing.ePane.setContentType('text/groovy')
}
}
}
}
Original comment by FGregu...@gmail.com
on 9 Sep 2011 at 10:20
Original issue reported on code.google.com by
FGregu...@gmail.com
on 9 Sep 2011 at 9:45