Using javax.swing import JOptionPane issues

Hi,

trying to use the JOptionpane in Processing and get following message:

java.lang.reflect.InaccessibleObjectException: Unable to make public abstract javax.swing.TransferHandler javax.swing.TransferHandler$HasGetTransferHandler.getTransferHandler() accessible: module java.desktop does not “opens javax.swing” to unnamed module @256216b3

Anyone knows how to fix this?

1 Like

May we see the source code that generates this error message?

1 Like

Sure, this is the code:

import json
from javax.swing import JOptionPane

parteifarben = {
1: color(30,144,255), #FDP
2: color(255,97,3), #CVP
3: color(235,0,0), #SP
4: color(34,139,34), #SVP
5: color(255,215,0), #EVP
6: color(255,0,0), #PdA/Sol.
7: color(0,255,0), #Grüne
8: color(214,214,214), #EDU
9: color(0,0,255), #Lega
10: color(0,205,0), #GLP
11: color(0,0,0) #BDP
}

parteinamen = {
1: “FDP”,
2: “CVP”,
3: “SP”,
4: “SVP”,
5: “EVP”,
6: “PdA”,
7: “GPS”,
8: “EDU”,
9: “LEGA”,
10: “GLP”,
11: “BDP”
}

def setup():
size(500, 500)
background(255, 255, 255)
f = open(‘nrw_test.json’)
global data
global kanton
data = json.load(f)
kanton = input(‘Bitte geben Sie den Kantonsnamen auf Deutsch ein:’)

def draw():
background(255, 255, 255)
fill(0, 0, 0)
textSize(18)
text(kanton, 40, 70)
xPos = 30
for datensatz in range (0,189):
anzahl = data[datensatz][“anzahl_gewaehlte”]
if data[datensatz][“kanton_bezeichnung”] == kanton:
if data[datensatz][“anzahl_gewaehlte”] > 0:
fill(parteifarben[data[datensatz][“partei_id”]])
figur(xPos, 350, anzahl8)
textSize(13)
text(data[datensatz][“anzahl_gewaehlte”],xPos + anzahl
3,370)
for z in range (1,12):
if data[datensatz][“partei_id”] == z:
fill(parteifarben[z])
text(parteinamen[z],xPos + anzahl3,430)
rect(xPos + anzahl
3,400,10,10)
else:
pass
xPos = xPos + anzahl*8 + 20
else:
pass
else:
pass

def input(message):
return JOptionPane.showInputDialog(frame, message)

def figur(xPos, yPos, anzahl):
triangle(xPos, yPos, xPos + anzahl, yPos, xPos + anzahl/2, yPos - anzahl*1.5)
circle(xPos + anzahl/2, yPos - anzahl/0.7, anzahl/1.5)

Are you using ‘Python’?

Yeah, exactly using Python on processing

There are some members in this forum who use Python mode and I will defer to them.

1 Like

how-to-use-input-with-python-processing-running-on-a-mac

2 Likes