早教吧 育儿知识 作业答案 考试题库 百科 知识分享

大家帮我看下哪里错了啊packagefanjin;importjava.awt.*;importjavax.swing.*;publicclassInfomationextendsJFrame{privateJLabeltitleLabel=newJLabel("Title:",SwingConstants.RIGHT);privateJTextFieldtitle;privateJLabeladdressLabel=

题目详情
大家帮我看下哪里错了啊
package fanjin;
import java.awt.*;
import javax.swing.*;
public class Infomation extends JFrame{
private JLabel titleLabel = new JLabel("Title:",SwingConstants.RIGHT);
private JTextField title;
private JLabel addressLabel =new JLabel("Address",SwingConstants.RIGHT);
private JTextField address;
private JLabel typeLabel =new JLabel("Type",SwingConstants.RIGHT);
private JTextField type;
public Infomation()
{
super("Site Infomation");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
String response1 = JOptionPane.showInputDialog(null,"Enter the site title");
title = new JTextField(response1,20);
String response2 = JOptionPane.showInputDialog(null,"Enter the address ");
address = new JTextField(response2,20);
String[]choices ={"Personal","Commercial","Unknow"};
//int response3 =JOptionPane.showInputDialog(null,"What type of site is it?");
int response3 =JOptionPane.showOptionDialog(null,"What type of site is it?","Site Type",0,"JOptionPanel.OUESTION_MESSAGE",null,choices,choices[0]);
type = new JTextField(choices[response3],20);
JPanel pane =new JPanel();
pane.setLayout(new GridLayout(3,2));
pane.add(titleLabel);
pane.add(title);
pane.add(addressLabel);
pane.add(address);
pane.add(typeLabel);
pane.add(type);
setContentPane(pane);
}
public static void main(String[] args) {
try{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}catch(Exception e){
System.err.print("Couldn't use the system"+"look and feel :"+e);
}
JFrame frame = new Infomation();
frame.pack();
frame.setVisible(true);
}
}
报错是
Exception in thread "main" java.lang.Error:Unresolved compilation problem:
The method showInputDialog(Component,Object,String,int,Icon,Object[],Object) in the type JOptionPane is not applicable for the arguments (null,String,String,int,String,null,String[],String)
at fanjin.Infomation.(Infomation.java:22)
at fanjin.Infomation.main(Infomation.java:42)
▼优质解答
答案和解析
JOptionPane.showOptionDialog(null,"What type of site is it?","Site Type",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE,null,choices,choices[0]);你的参数不对 详细可以看看java api JOptio...