Jython/Python and javax.swing.*

S

Sherrod Faulks

I'm using Jython and in the python script I do:

from javax import swing
result = javax.swing.JOptionPane.showInputDialog(wC, cmd[8:],"Prompt
from " + client.serverName, JOptionPane.PLAIN_MESSAGE)

wC is a JFrame, cmd is a String and client.serverName is a String.
It won't show the JOptionPane, why?
 
J

John Crichton

Sherrod Faulks said:
I'm using Jython and in the python script I do:

from javax import swing
result = javax.swing.JOptionPane.showInputDialog(wC, cmd[8:],"Prompt
from " + client.serverName, JOptionPane.PLAIN_MESSAGE)

wC is a JFrame, cmd is a String and client.serverName is a String.
It won't show the JOptionPane, why?

Hi Sherrod,

Hope this helps. It's a bit longer than your script. (I've also
changed
'client.serverName' to 'client_serverName' to make my script work -
but this is only cosmetic and 'client.serverName' will work fine in
your script assuming
it resolves to a string.)

import javax.swing.JOptionPane as JOptionPane
import javax.swing.JFrame as JFrame
wC = JFrame('jython')
cmd = 'JythonJython'
client_serverName = 'name'
result = JOptionPane.showInputDialog(wC, cmd[8:],"Prompt from " +
client_serverName, JOptionPane.PLAIN_MESSAGE)

Best wishes,

John
 
J

John Crichton

Sherrod Faulks said:
I'm using Jython and in the python script I do:

from javax import swing
result = javax.swing.JOptionPane.showInputDialog(wC, cmd[8:],"Prompt
from " + client.serverName, JOptionPane.PLAIN_MESSAGE)

wC is a JFrame, cmd is a String and client.serverName is a String.
It won't show the JOptionPane, why?

Hi Sherrod,

Having had a look at my last post after a nights sleep I'm not sure it
was very clear...

If you change your script to the following it should work:

import javax.swing as swing
result = swing.JOptionPane.showInputDialog(wC, cmd[8:],"Promptfrom " +
client.serverName, swing.JOptionPane.PLAIN_MESSAGE)

Cheers,

John
 
S

Sherrod Faulks

John,
Sorry I didn't reply earlier, but I found out how to do it in the
Jython Doc. You must do:

from pawt import swing

Thanks for helping, though!

Sherrod Faulks said:
I'm using Jython and in the python script I do:

from javax import swing
result = javax.swing.JOptionPane.showInputDialog(wC, cmd[8:],"Prompt
from " + client.serverName, JOptionPane.PLAIN_MESSAGE)

wC is a JFrame, cmd is a String and client.serverName is a String.
It won't show the JOptionPane, why?

Hi Sherrod,

Having had a look at my last post after a nights sleep I'm not sure it
was very clear...

If you change your script to the following it should work:

import javax.swing as swing
result = swing.JOptionPane.showInputDialog(wC, cmd[8:],"Promptfrom " +
client.serverName, swing.JOptionPane.PLAIN_MESSAGE)

Cheers,

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top