blob: debe9b975384b5cd606b650021982c612efe1e6c (
plain)
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
|
"""
A hack to make pawt.swing point to the java swing library.
This allows code which imports pawt.swing to work on both JDK1.1 and 1.2
"""
swing = None
try:
import javax.swing.Icon
from javax import swing
except (ImportError, AttributeError):
try:
import java.awt.swing.Icon
from java.awt import swing
except (ImportError, AttributeError):
try:
import com.sun.java.swing.Icon
from com.sun.java import swing
except (ImportError, AttributeError):
raise ImportError, 'swing not defined in javax.swing or java.awt.swing or com.sun.java.swing'
import sys
def test(panel, size=None, name='Swing Tester'):
f = swing.JFrame(name, windowClosing=lambda event: sys.exit(0))
if hasattr(panel, 'init'):
panel.init()
f.contentPane.add(panel)
f.pack()
if size is not None:
from java import awt
f.setSize(apply(awt.Dimension, size))
f.setVisible(1)
return f
if swing is not None:
import pawt, sys
pawt.swing = swing
sys.modules['pawt.swing'] = swing
swing.__dict__['test'] = test
#These two lines help out jpythonc to figure out this very strange module
swing.__dict__['__file__'] = __file__
swing.__dict__['__jpythonc_name__'] = 'pawt.swing'
|