报的错误
F:\javaWS\javaTXT>javac Example6_6.java
Example6_6.java:10: 错误: 对super的调用必须是构造器中的第一个语句
super(s);
^
Example6_6.java:37: 错误: 无法将类 MyDialog中的构造器 MyDialog应用到给定类型;
dialog = new MyDialog(this,"水果");
^
需要: 没有参数
找到: MyWindow,String
原因: 实际参数列表和形式参数列表长度不同
Example6_6.java:42: 错误: 无法将类 MyDialog中的构造器 MyDialog应用到给定类型;
dialog =new MyDialog(this,"食品");
^
需要: 没有参数
找到: MyWindow,String
原因: 实际参数列表和形式参数列表长度不同
Example6_6.java:53: 错误: 对super的调用必须是构造器中的第一个语句
super(F,s,true);//模态
^
Example6_6.java:77: 错误: 无法将类 MyWindow中的构造器 MyWindow应用到给定类型;
window = new MyWindow("带对话框窗口");
^
需要: 没有参数
找到: String
原因: 实际参数列表和形式参数列表长度不同
5 个错误
F:\javaWS\javaTXT>javac Example6_6.java
Example6_6.java:10: 错误: 对super的调用必须是构造器中的第一个语句
super(s);
^
Example6_6.java:37: 错误: 无法将类 MyDialog中的构造器 MyDialog应用到给定类型;
dialog = new MyDialog(this,"水果");
^
需要: 没有参数
找到: MyWindow,String
原因: 实际参数列表和形式参数列表长度不同
Example6_6.java:42: 错误: 无法将类 MyDialog中的构造器 MyDialog应用到给定类型;
dialog =new MyDialog(this,"食品");
^
需要: 没有参数
找到: MyWindow,String
原因: 实际参数列表和形式参数列表长度不同
Example6_6.java:53: 错误: 对super的调用必须是构造器中的第一个语句
super(F,s,true);//模态
^
Example6_6.java:77: 错误: 无法将类 MyWindow中的构造器 MyWindow应用到给定类型;
window = new MyWindow("带对话框窗口");
^
需要: 没有参数
找到: String
原因: 实际参数列表和形式参数列表长度不同
5 个错误
解决方案 »
- 一个基础问题,如何通过接口调用这个接口的实现类
- 传值
- 矩阵屏幕输入初始化问题...还请帮忙指教
- 请问java中有没有对数组的最大长度作限制?那最大长度是多少?
- 文件复制问题
- [请教]为什么有些方法可以直接写,不用加对象名或类名
- java下如何得到当前程序(application)的路径?很急!!
- arraylist与vector有何区别,用那一个好些?
- 用什么可以动态显示测试数据?JTextArea? JTextField ??
- jdk1.3中关于corba的问题?
- linux下Java文件操作、Ftp上传文件不完整问题-【急急急急急急急急急急急急】
- 做毕业设计遇到麻烦了,求各位大神帮帮忙!怎样将服务器中的list对象,发到各个客户端的线程里面。
去掉void 试试,构造函数不能有返回类型,连void也不能有。加上void就不认为是构造函数了。
import java.applet.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class MyWindow extends JFrame implements ActionListener{
private JButton button1,button2;
private static int flg=0;
private static JTextField text1,text2;
void MyWindow(String s){
super(s);//这里
Container con = this.getContentPane();
con.setLayout(new GridLayout(2,2));
this.setSize(200,100);
this.setLocation(100,100);
button1 = new JButton("选择水果");
button2 = new JButton("选择食品");
button1.addActionListener(this);
button2.addActionListener(this);
text1 = new JTextField(20);
text2 = new JTextField(20);
con.add(button1);
con.add(button2);
con.add(text1);
con.add(text2);
this.setVisible(true);
this.pack();
}
public static void returnName(String s){
if(flg ==1)
text1.setText("选择的水果是:"+s);
else if(flg == 2)
text2.setText("选择的食品是:"+s);
}
public void actionPerformed(ActionEvent e){
MyDialog dialog;
if(e.getSource()==button1){
dialog = new MyDialog(this,"水果");
dialog.setVisible(true);
flg =1;
}
else if(e.getSource()==button2){
dialog =new MyDialog(this,"食品");
dialog.setVisible(true);
flg=2;
}
}
}
class MyDialog extends JDialog implements ActionListener{
JLabel title;
JTextField text;
JButton done;
void MyDialog(JFrame F,String s){
super(F,s,true);//模态 ////和这里
Container con = this.getContentPane();
title = new JLabel("输入"+s+"名称");
text = new JTextField(10);
text.setEditable(true);
con.setLayout(new FlowLayout());
con.setSize(200,100);
setModal(false);
done = new JButton("确定");
done.addActionListener(this);
con.setVisible(true);
this.pack();
}
public void actionPerformed(ActionEvent e){
MyWindow.returnName(text.getText());
setVisible(false);
dispose();
}
}
public class Example6_6 extends Applet{
public static void main(String[] args){
MyWindow window;
MyDialog dialog;
window = new MyWindow("带对话框窗口");
}
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class MyWindow extends JFrame implements ActionListener{
private JButton button1,button2;
private static int flg=0;
private static JTextField text1,text2;
MyWindow(String s){//注意构造函数的写法
//super();//这里
Container con = this.getContentPane();
con.setLayout(new GridLayout(2,2));
this.setSize(200,100);
this.setLocation(100,100);
button1 = new JButton("选择水果");
button2 = new JButton("选择食品");
button1.addActionListener(this);
button2.addActionListener(this);
text1 = new JTextField(20);
text2 = new JTextField(20);
con.add(button1);
con.add(button2);
con.add(text1);
con.add(text2);
this.setVisible(true);
this.pack();
}
public static void returnName(String s){
if(flg ==1)
text1.setText("选择的水果是:"+s);
else if(flg == 2)
text2.setText("选择的食品是:"+s);
}
public void actionPerformed(ActionEvent e){
MyDialog dialog;
if(e.getSource()==button1){
dialog = new MyDialog("水果");
dialog.setVisible(true);
flg =1;
}
else if(e.getSource()==button2){
dialog =new MyDialog("食品");
dialog.setVisible(true);
flg=2;
}
}
}
class MyDialog extends JDialog implements ActionListener{
JLabel title;
JTextField text;
JButton done;
MyDialog(String s){//没用的参数不要传进去
// super(F,s,true);//模态 ////和这里
Container con = this.getContentPane();
title = new JLabel("输入"+s+"名称");
text = new JTextField(10);
text.setEditable(true);
con.setLayout(new FlowLayout());
con.setSize(200,100);
setModal(false);
done = new JButton("确定");
done.addActionListener(this);
con.setVisible(true);
this.pack();
}
public void actionPerformed(ActionEvent e){
MyWindow.returnName(text.getText());
setVisible(false);
dispose();
}
}
public class Example6_6 extends Applet{
public static void main(String[] args){
MyWindow window;
MyDialog dialog;
window = new MyWindow("带对话框窗口");
}
}