java.lang.RuntimeException: JOptionPane: type must be one of JOptionPane.ERROR_MESSAGE, JOptionPane.INFORMATION_MESSAGE, JOptionPane.WARNING_MESSAGE, JOptionPane.QUESTION_MESSAGE or JOptionPane.PLAIN_MESSAGE

Olá, tudo bem?

Estou desenvolvendo um programa e logo no começo aparece esse erro:

java.lang.RuntimeException: JOptionPane: type must be one of JOptionPane.ERROR_MESSAGE, JOptionPane.INFORMATION_MESSAGE, JOptionPane.WARNING_MESSAGE, JOptionPane.QUESTION_MESSAGE or JOptionPane.PLAIN_MESSAGE

public class Main {

public static void main(String[] args) {
	// TODO Auto-generated method stub		
	
	Cliente[] clientes = new Cliente[7];
	
	int opcaoCliente;
	int opcao;
	Scanner leitor = new Scanner(System.in);
	
	int posicao = 0;
	
	do {
		
		opcao = parseInt(showInputDialog(menu()));
		if (opcao < 1 || opcao > 6) {
			showMessageDialog(null, "Opção inválida", "ALERTA", ERROR);
		}

De onde está vindo essa variável ERROR?

Veja um exemplo de uso de JOptionPane:

JOptionPane.showMessageDialog(null, "Opção inválida", "ALERTA", JOptionPane.ERROR_MESSAGE);
1 curtida

O método showMessageDialog para quatro parâmetros é o seguinte:

showMessageDialog​(Component parentComponent, Object message, String title, int messageType)

Então, creio eu, no seu caso deveria ser algo como:

showMessageDialog(null, "Opção inválida", "ALERTA", JOptionPane.ERROR_MESSAGE)

se for usar o tipo de mensage de erro fornecido pela classe JOptionPane como a própria exceção sugere.