Rengaw Rengaw - 6 months ago 28x
Java Question

Error with showMessageDialog:The method showMessageDialog(Component, Object) in the type JOptionPane is not applicable for the arguments (null, void)

Just want to begin by saying i'm a beginner in Java. So what i'm trying to do here is call a method from another class.

I'm trying to call the method from this class

import javax.swing.JOptionPane;

public class age {

public static void mpd(int sub1){
if (sub1<15)
JOptionPane.showMessageDialog(null, "You're too young ");
JOptionPane.showMessageDialog(null, "You're ok ");

Here's where i'm calling the method from the age-class.

import javax.swing.*;
public class mn4 {

public static void main(String[] args) {
// TODO Auto-generated method stub

JOptionPane.showMessageDialog(null, age.mpd(5));



I want the MessageDialog to say if i'm too young or old but i keep getting the error i posted on the title.


Your main method should look like:

public static void main(String[] args) {