Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't play nice with Groovy's SwingBuilder #178

Open
GoogleCodeExporter opened this issue Sep 22, 2015 · 2 comments
Open

Doesn't play nice with Groovy's SwingBuilder #178

GoogleCodeExporter opened this issue Sep 22, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1.Use Groovy's SwingBuilder API to try creating an editorPane with content type 
'text/groovy'
2.
3.

What is the expected output? What do you see instead?
I would expect a working editor pane. Instead it throws an exception stating 
"Sep 9, 2011 4:42:00 PM jsyntaxpane.components.LineNumbersRuler install
WARNING: JEditorPane is not enclosed in JScrollPane, no LineNumbers will be 
displayed
Caught: java.lang.NullPointerException"

What version of the product are you using? On what operating system?
0.9.5-b29 on Win XP SP3

Please provide any additional information below.
Example script:

import groovy.swing.SwingBuilder
import java.awt.Component
import javax.swing.BoxLayout
import javax.swing.border.EmptyBorder

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 issue reported on code.google.com by [email protected] on 9 Sep 2011 at 9:45

@GoogleCodeExporter
Copy link
Author

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 [email protected] on 9 Sep 2011 at 9:46

@GoogleCodeExporter
Copy link
Author

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 [email protected] on 9 Sep 2011 at 10:20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant