/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/package text ;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JTextField;
/**
*
* @author Administrator
*/
public class Main { /**
* @param args the command line arguments
*/public class HelloWorld extends JFrame {
public HelloWorld()
{
JTextField text = new JTextField("Hello, world");
this.getContentPane().add(text);
}
public void main(String argv[])
{
HelloWorld win = new HelloWorld();
Toolkit tk = Toolkit.getDefaultToolkit();int Width = tk.getScreenSize().width;
int Height = tk.getScreenSize().height;// 设定大小和位置
win.setSize(100, 100);
win.setLocation((Width - 100) / 2, (Height - 100) / 2);// 显示
win.setVisible(true);
win.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
}
输出的是run:
java.lang.NoSuchMethodError: main
Exception in thread "main" Java Result: 1
成功生成(总时间:0 秒)大家帮帮忙看看是什么问题啊
谢谢大家;了
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/package text ;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JTextField;
/**
*
* @author Administrator
*/
public class Main { /**
* @param args the command line arguments
*/public class HelloWorld extends JFrame {
public HelloWorld()
{
JTextField text = new JTextField("Hello, world");
this.getContentPane().add(text);
}
public void main(String argv[])
{
HelloWorld win = new HelloWorld();
Toolkit tk = Toolkit.getDefaultToolkit();int Width = tk.getScreenSize().width;
int Height = tk.getScreenSize().height;// 设定大小和位置
win.setSize(100, 100);
win.setLocation((Width - 100) / 2, (Height - 100) / 2);// 显示
win.setVisible(true);
win.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
}
输出的是run:
java.lang.NoSuchMethodError: main
Exception in thread "main" Java Result: 1
成功生成(总时间:0 秒)大家帮帮忙看看是什么问题啊
谢谢大家;了
java.lang.NoSuchMethodError: main
Exception in thread "main" Java Result: 1
要学会看异常啊,不要一看到异常就像看到蛇一样。要镇定! 先百度再CSDN!
帮你改了
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JTextField;/**
*
* @author Administrator
*/
public class HelloWorld extends JFrame { public HelloWorld() {
JTextField text = new JTextField("Hello, world");
this.getContentPane().add(text);
} public static void main(String[] argv) {
HelloWorld win = new HelloWorld();
Toolkit tk = Toolkit.getDefaultToolkit(); int Width = tk.getScreenSize().width;
int Height = tk.getScreenSize().height;// 设定大小和位置
win.setSize(100, 100);
win.setLocation((Width - 100) / 2, (Height - 100) / 2);// 显示
win.setVisible(true);
win.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
Exception in thread "main" Java Result: 1
成功生成(总时间:0 秒)这段错误代码说的是:
没有发现主函数
就是因为:
public void main(String argv[])应该写成public void main(String args[])