2

I am trying to make a simple button that updates a number but when I click on the button, I get this error: Exception in thread "AppKit Thread" java.lang.NoSuchMethodError: accessibilityHitTest

Version on my Mac M1 chip

openjdk 17.0.2 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8-86)
OpenJDK 64-Bit Server VM (build 17.0.2+8-86, mixed mode, sharing)

Does anyone know how to fix this? I searched on google but there are no real solutions and I am new to Java so I don't really know where to start.

Code that I use

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

public class Scherm extends JFrame implements ActionListener {

    private Voorstelling voorstelling;
    private JLabel jlAantalPlaatsen;
    private JLabel jlAantalVerkochtePlaatsen;

    private JTextField jtAantalVerkopen;
    private JTextField jtAantalAnnuleren;

    public Scherm(Voorstelling voorstelling) {
        this.voorstelling = voorstelling;

        setTitle("Voorstelling " + voorstelling.getNaam());
        setSize(300, 200);
        setLayout(new GridLayout(5, 2));

        add(new JLabel("aantal plaatsen vrij:"));
        String aantalPlaatsen = String.valueOf(voorstelling.getAantalPlaatsen());
        jlAantalPlaatsen = new JLabel(aantalPlaatsen);
        add(jlAantalPlaatsen);

        add(new JLabel("aantal verkocht:"));
        String aantalVerkochtePlaatsen = String.valueOf(voorstelling.getAantalVerkocht());
        jlAantalVerkochtePlaatsen = new JLabel(aantalVerkochtePlaatsen);
        add(jlAantalVerkochtePlaatsen);

        JButton button = new JButton("Verkoop kaartje");
        add(button);
        button.addActionListener(this);

        setVisible(true);
    }
    public void actionPerformed(ActionEvent evt)
    {

    }
}
Raccoon
  • 99
  • 8
  • this might be helpful. the error doesn't seem familiar to me, though. https://stackoverflow.com/questions/70112706/java-lang-nosuchmethoderror-accessibilityhittest – Stultuske Mar 15 '22 at 14:26

1 Answers1

0

The same thing here for every project. I updated my MacBook Pro M1 to Azul JDK 18.0.2+9 for ARM 64Bit V8. This did the job for me!

Euklid
  • 21
  • 3