早教吧作业答案频道 -->其他-->
大家帮我看下哪里错了啊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)
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...
看了大家帮我看下哪里错了啊pack...的网友还看了以下:
一道英语题以下句子是哪种句型1.简单句:S+V、S+V+O、S+V+P、主谓双宾结构、主谓宾补结构 2020-05-13 …
英语中S+V+P,S+V,S+V+O,S+V+O+O和S+V+O+C句型是指什么? 2020-06-12 …
S+B、S+V+P、S+V+O、D+V+InO、S+V+O+C是什么意思在英语句子中 2020-06-12 …
判断下列句子的种类:1.S+V;2.S+V+O;3.S+V+P;4.S+V+INO+DO;5.S+ 2020-06-12 …
以爱为主题的作文356个字艉N∽∽w“※~↗^i↓V狐o匕首页面啊!母④㏄尼姑庵g.心情的事?≥~ 2020-06-29 …
英语——句型成分及类型专练从方框中选出给下列各题选出相匹配的选项.AS+VBS+V+OCS+V+P 2020-07-16 …
英语中,S+V+P,S+V,S+V+O,S+V+INO+DO,S+V+O+OC,这些个表示什么? 2020-07-24 …
判断下列句子属于5种类型基本句型中的哪种类型用(S+V)(S+V+P)(S+V+O)(S+V+INO 2020-11-01 …
我们常见春季路旁栽种较大的树时,绿化工人总将树的枝蔓全部锯掉,请你解释这种做法的意义好快考试了呀,o 2020-11-04 …
校长经常深入群众,征求大家的意见.改病句.急o(≧v≦)o~o(≧v≦)o~o(≧v≦)o~o(≧v 2020-12-29 …