早教吧作业答案频道 -->其他-->
大家帮我看下哪里错了啊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...的网友还看了以下:
在正方体ABCD-A1B1C1D1中,O是BD1中点,A1C交平面AB1D1于M.则以下说法中:( 2020-05-17 …
英语单词辨音找出画()部分读音与其余不同的单词()1.A .kn(ee) B.n(e)ck C.r 2020-05-17 …
若⊙O所在平面内一点P到⊙O上的点的最大距离为m,最小距离为n(m>n),则此圆的半径为()A.m 2020-06-27 …
如图所示,一簇电场线的分布关于y轴对称,O是坐标原点,M、N、P、Q是以O为圆心的一个圆周上的四个 2020-07-01 …
如图所示,一簇电场线的分布关于y轴对称,O是坐标原点,M、N、P、Q是以O为圆心的一个圆周上的四个 2020-07-22 …
将长度为n的单链表链接在长度为m的单链表之后的算法的时间复杂度为()A.O(1)B.O(n)C.O 2020-07-23 …
已知两个长度分别为m和n的升序链表若将它们合并为一个长度为m+n的降序链表,则最坏情况下的时间复杂度 2020-11-28 …
读某地近地面和高空四点气压图(单位:hPa)(如图),回答3-4题.若近地面和高空四点构成热力环流, 2020-12-04 …
如图所示,一簇电场线的分布关于y轴对称,O是坐标原点,M、N、P、Q是以O为圆心的一个圆周上的四个点 2020-12-09 …
如图,矩形OABC在平面直角坐标系中,A(0,4),C(8,0),动点M,N分别从O,A同时出发,点 2020-12-25 …