I can not call JOptionPane in Eclipse

1

Well, I'm not able to call JOptionPane in any class in eclipse, I tried Netbeans, and it ran normal. Can anyone here know what it can be?

Error message:

  Multiple markers at this line   - Access restriction: The type JOptionPane is not accessible due to restriction on required library C: \ Program   Files \ Java \ jre1.8.0_73 \ lib \ rt.jar   - Access restriction: The method showMessageDialog (Component, Object) from the type JOptionPane is not accessible due to restriction on   required library C: \ Program Files \ Java \ jre1.8.0_73 \ lib \ rt.jar

Code:

package br.projeto.model;
import javax.swing.*;
public class Caixa {

Cliente client = new Cliente();

public void showAvaibleBalance(Cliente client){
    client.getBalance();
}

public void makeLoot(Cliente client, double value){
    if((value > 0)&&(value < client.getBalance())){
        client.setBalance(client.getBalance()-value);
    }else if (value < 0){
        JOptionPane.showMessageDialog(null, "");
    }
}
}
    
asked by anonymous 05.03.2016 / 18:49

1 answer

3

Perform the following procedures to resolve this problem:

  • Window menu - > "Preferences"
  • In the window that opens, expand "Java" - > "Compiler" and choose "Errors / Warnings"
  • On the right side, expand "Deprecated and restricted API" and "Forbidden reference (access rules)" select "Ignore"
  • Click "OK"
  • Eclipse will ask for confirmation. Choose "Yes" and wait for him recompile the classes.
  • Source: link

        
    05.03.2016 / 19:08