在java中,出现了问题说缺少方法主体,或者声明抽象 20
//youxiang.javaimpackagelianxi;importjava.awt.EventQueue;importjavax.swing.JFrame;imp...
//youxiang.java
impackage lianxi;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JTextField;
import java.awt.FlowLayout;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JPasswordField;
import javax.swing.JButton;
public class Login extends JFrame {
private JPanel contentPane;
private JTextField textField;
private JPasswordField passwordField;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Login frame = new Login();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public Login() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
JLabel label = new JLabel("\u90AE\u7BB1");
contentPane.add(label);
textField = new JTextField();
textField.setText("\u7528\u6237\u540D");
contentPane.add(textField);
textField.setColumns(20);
JLabel label_1 = new JLabel("@");
contentPane.add(label_1);
JComboBox comboBox = new JComboBox();
comboBox.setModel(new DefaultComboBoxModel(new String[] {"263.net", "qq.com", "sina.com"}));
contentPane.add(comboBox);
JLabel label_2 = new JLabel("\u5BC6\u7801");
contentPane.add(label_2);
passwordField = new JPasswordField();
passwordField.setColumns(20);
contentPane.add(passwordField);
JButton button = new JButton("\u767B\u9646");
contentPane.add(button);
pack();
}
} 展开
impackage lianxi;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JTextField;
import java.awt.FlowLayout;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JPasswordField;
import javax.swing.JButton;
public class Login extends JFrame {
private JPanel contentPane;
private JTextField textField;
private JPasswordField passwordField;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Login frame = new Login();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public Login() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
JLabel label = new JLabel("\u90AE\u7BB1");
contentPane.add(label);
textField = new JTextField();
textField.setText("\u7528\u6237\u540D");
contentPane.add(textField);
textField.setColumns(20);
JLabel label_1 = new JLabel("@");
contentPane.add(label_1);
JComboBox comboBox = new JComboBox();
comboBox.setModel(new DefaultComboBoxModel(new String[] {"263.net", "qq.com", "sina.com"}));
contentPane.add(comboBox);
JLabel label_2 = new JLabel("\u5BC6\u7801");
contentPane.add(label_2);
passwordField = new JPasswordField();
passwordField.setColumns(20);
contentPane.add(passwordField);
JButton button = new JButton("\u767B\u9646");
contentPane.add(button);
pack();
}
} 展开
展开全部
问题可能原因:
1、方法声旁源明时让启乱未提供方法体
public class Test{
public void show();
}
2、方法声坦档明时在方法体前有分号,导致方法体无法识别
public class Test{
public void show();{
System.out.println("ok");
}
}
3、该类继承了抽象类或实现了接口未重写抽象方法
public abstract class Base{
public void show();
}
public class Test extends Base{
public void print(){
System.out.println("print");
}
}
1、方法声旁源明时让启乱未提供方法体
public class Test{
public void show();
}
2、方法声坦档明时在方法体前有分号,导致方法体无法识别
public class Test{
public void show();{
System.out.println("ok");
}
}
3、该类继承了抽象类或实现了接口未重写抽象方法
public abstract class Base{
public void show();
}
public class Test extends Base{
public void print(){
System.out.println("print");
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询