What am I doing wrong and how to fix it? I'm running this on eclipse.
import java.awt.Component;
import javax.swing.Icon;
public class JOptionPane {
public static void main(String[] args) {
// JOptionPane inputs
Component parentComponent = null;
Object message = "What do you think of Hudson?";
String title = "VERY IMPORTANT!";
String choice1 = "1";
String choice2 = "2";
String choice3 = "3";
int optionType = JOptionPane.YES_NO_OPTION;
int messageType = JOptionPane.ERROR_MESSAGE;
Icon icon = null;
// JOption pane display
Object[] options = { choice1, choice2, choice3 };
int option = JOptionPane.showOptionDialog(parentComponent, message, title,
optionType, messageType, icon, options, options[2]);
// Switch
switch (option) {
case 0:
//Button 1 result
break;
case 1:
//Button 2 result
break;
default:
//Button 3 result
break;
}
return;
}
}
The errors:
Your class name is conflicting with javax.swing.JOptionPane
- rename it to something else so you can import that class