早教吧作业答案频道 -->其他-->
大家帮我看下哪里错了啊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...的网友还看了以下:
假设一物体从飞机上扔下,t秒后物体的下落速度近似为:v(t)=g(1-e^-kt)/k,(g=9. 2020-06-16 …
跪谢!已知两函数f(x)=8x²+16x-k,g(x)=2x³+跪谢!已知两函数f(x)=8x²+ 2020-07-07 …
二叉树先序序列为E,F,H,I,G,J,K中序序列为H,F,I,E,J,K,G,那么这棵树是怎么排 2020-07-10 …
三元一次方程组a*x+b*y+c*z+d=0,e*x+f*y+g*z+h=0,i*x+j*y+k* 2020-08-03 …
无穷级数的求解t取1到正无穷1、∑1/(1+k)^t=1/k;2、∑(1+g)^t/(1+k)^t, 2020-10-31 …
一道行测题.没看懂解析已知ABCDEFGHIK代表十个互不相同的大于0的自然数,要使下列等式成立,A 2020-11-01 …
(二二14•怀化三模)已知;①Fe(s)+Cu二(g)⇌Feu(s)+Cu(g)△H=得kJ•mul 2020-11-12 …
家有7岁小男孩,有点卷舌,医院检查没毛病,拼音不会K.g.x.家有7岁小男孩,有点卷舌,医院检查没毛 2020-11-14 …
设f(x)=x/(e^-2+x^2),g(x)=(e^x)/x对任意x1若有恒成立,则正数k的取值范 2020-12-22 …
设f(x)=x/(e^-2+x^2),g(x)=(e^x)/x对任意x1若有恒成立,则正数k的取值范 2020-12-22 …