java-实在搞不懂,这里的大错特错。求助

实在搞不懂,这里的荒谬。求助
package viewer;import java.awt.BorderLayout;import java.awt.Dialog;import java.awt.FlowLayout;import java.awt.GridLayout;import java.awt.HeadlessException;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javafx.scene.layout.Border;import javax.swing.JButton;import javax.swing.JDialog;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JScrollBar;import javax.swing.JScrollPane;import javax.swing.JTable;import javax.swing.JTextField;import util.EmpUtil;import model.EmpException;import model.User;public class UserPanel extends JPanel { private static final long serialVersionUID = 1L; private JPanel jp1, jp2; private JLabel jl1; private JTable jt; private JScrollPane jsp; private JButton jb1, jb2, jb3; private JTable jtable; private UserTableModel usermodel; private AddDialog ad; private JFrame jf; public UserPanel(JFrame jf卡塔尔(قطر‎ { this.setLayout(new BorderLayout; this.jf = jf; jp1 = new JPanel(State of Qatar; jp2 = new JPanel(卡塔尔(قطر‎; jl1 = new JLabel; jb1 = new JButton; jb1.addActionListener(new UserManagerClick; jb2 = new JButton; jb2.addActionListener(new UserManagerClick; jb3 = new JButton; jb3.addActionListener(new UserManagerClick; jp1.add; jp2.add; jp2.add; jp2.add; usermodel = new UserTableModel(卡塔尔(قطر‎; jtable = new JTable(usermodel卡塔尔; jsp = new JScrollPane; this.add(jp1, BorderLayout.NORTH卡塔尔(قطر‎; this.add(jp2, BorderLayout.SOUTH卡塔尔(قطر‎; this.add; } private class UserManagerClick implements ActionListener { @Override public void actionPerformed(Action伊夫nt eState of Qatar { if (e.getSource { // 增加 ad = new AddDialog(卡塔尔(قطر‎; } else if (e.getSource { // 删除 } else if (e.getSource { // 修改 } } } private class AddDialog extends JDialog { private JLabel jl1, jl2, jl3; private JButton jb1, jb2; private JPanel jp1, jp2, jp3, jp4; private JTextField jtf1, jtf2; private JPasswordField jpf; private JDialog jdg=this; public AddDialog(卡塔尔 { this.setSize; this.setModal; // 设置为模态对话框,不可能操作主窗体。倘若这里用JFrame就不或然贯彻该功效了。 this.setLocation + 50, jf.getY; this.setTitle; this.setLayout(new GridLayout; jp1 = new JPanel(卡塔尔(قطر‎; jp2 = new JPanel(卡塔尔国; jp3 = new JPanel(卡塔尔(قطر‎; jp4 = new JPanel(卡塔尔; jl1 = new JLabel; jl2 = new JLabel; jl3 = new JLabel; jb1 = new JButton;jb1.addActionListener(new AddDialogClick; jb2 = new JButton;jb2.addActionListener(new AddDialogClick; jtf1 = new JTextField; jtf2 = new JTextField; jpf = new JPasswordField; jp1.add; jp1.add; jp2.add; jp2.add; jp3.add; jp3.add; jp4.add; jp4.add; this.add; this.add; this.add; this.add; this.pack(卡塔尔国; this.setResizable; this.setVisible; } private void reset(卡塔尔 { jtf1.setText; jtf2.setText; jpf.setText; } private class AddDialogClick implements ActionListener { @Override public void actionPerformed(ActionEvent e卡塔尔国 { try { if (e.getSource { // 增添客商 String username=jtf1.getText(卡塔尔; if (username == null ||””.equals(username.trim { //归属哪个窗口就是当弹出提示对话框时,非归于的其余窗体全体隐形不呈现. / JOptionPane.showMessageDialog(jdg, “请输入正确的客户名!”, “发掘错误!”, JOptionPane.E瑞鹰ROHaval_MESSAGE);/ EmpUtil.showError(jdg, “请输入精确的顾客名!”State of Qatar; return;//必须得有return。固然弹出提示对话框,但是程序照旧持续往下实践的。 } String password=new String(jpf.getPassword; String nickname=jtf2.getText(卡塔尔; User u=new User(卡塔尔国; u.setUsername; u.setPassword; u.setNickname; usermodel.getUd; AddDialog.this.setVisible; //ad.dispose(卡塔尔(قطر‎; } else if (e.getSource { // 重置数据 reset(卡塔尔(قطر‎; } } catch (EmpException e1卡塔尔 { EmpUtil.showError(jdg, e1.getMessage; } } } }}

大神援救扫一眼呗,executeQuery和Statement的主题材料
public class Login extends JFrame implements ActionListener{//定义组件JPanel jp1,jp2,jp3,jp4;//面板JLabel jlb1,jlb2,jlb3;//标签JButton jb1,jb2,jb3;//开关JText菲尔德 jtf;//文本JPasswordField jpf;//密码JRadioButton jrb1,jrb2=null;//ButtonGroup bg=null;//设定顾客名和密码static String userword;static String password;Connection ct=null;Statement st=null;ResultSet rs=null;//布局函数public Login(卡塔尔国{ //创造面板 jp1=new JPanel(卡塔尔国; jp2=new JPanel(State of Qatar; jp3=new JPanel(卡塔尔国; jp4=new JPanel(State of Qatar; //创制标签 jlb1=new JLabel; jlb2=new JLabel; jlb3=new JLabel; //制造按键 jb1=new JButton; jb2=new JButton; jb3=new JButton; jb1.addActionListener; jb2.addActionListener; jb3.addActionListener; jrb1=new JRadioButton; jrb2=new JRadioButton; bg=new ButtonGroup(State of Qatar; bg.add; bg.add; jrb2.setSelected; //创设文本框 jtf=new JTextField; //创造密码框 jpf=new JPassword菲尔德; //设置结构管理 this.setLayout(new GridLayout;//网格式布局 //参加各种零器件 jp1.add; jp1.add; jp2.add; jp2.add; jp3.add; jp3.add; jp3.add; jp4.add; jp4.add; jp4.add; //参预到JFrame this.add; this.add; this.add; this.add; //给窗口设置标题 this.setTitle(“学子成绩管理种类”State of Qatar; //设置窗体大小 this.setSize; //设置窗体带头地方 this.setLocation; //设置当关闭窗口时,保障JVM也退出 this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE卡塔尔; //展现窗体 this.setVisible; this.setResizable; //创设数据库 try { Class.forName(“org.gjt.mm.mysql.Driver”State of Qatar; ct=DriverManager.getConnection(“jdbc:mysql://127.0.0.1:3306/studentmanager”,”root”,”123456″卡塔尔(قطر‎; } catch (Exception e卡塔尔国 { // TODO: handle exception System.out.println; }}public static void main(String[] args卡塔尔(قطر‎ {new Login(卡塔尔;}@Overridepublic void actionPerformed(ActionEvent e卡塔尔 {// TODO Auto-generated method stubif(e.getActionCommand{ //假诺选中等教育师登陆 if(jrb1.isSelected { //成立火箭车 try { st=ct.createStatement(卡塔尔国;

import java.awt.Color; import java.awt.Container;  import java.awt.Image;  import java.awt.event.ActionEvent;  import java.awt.event.ActionListener;  import javax.swing.ImageIcon;  import javax.swing.JButton;  import javax.swing.JCheckBox;  import javax.swing.JComboBox;  import javax.swing.JFrame;  import javax.swing.JLabel;  import javax.swing.JOptionPane;  import javax.swing.JPasswordField;  import javax.swing.JTextField;  public class GUIQQ extends JFrame {  // 用户名  private JTextField username;  // 密码  private JPasswordField password;  // 小容器  private JLabel jl1;  private JLabel jl2;  private JLabel jl3;  private JLabel jl4;  // 小按钮  private JButton bu1;  private JButton bu2;  private JButton bu3;  // 复选框  private JCheckBox jc1;  private JCheckBox jc2;  // 列表框  private JComboBox jcb;  /*  * 布局方法  */  public GUIQQ(卡塔尔 {  // 设置窗口题目  this.setTitle(“QQ”卡塔尔;  // 窗体组件最初化  init(卡塔尔;  this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE卡塔尔;  // 设置布局方式为相对定位  this.setLayout(null卡塔尔国;  this.setBounds(0, 0, 355, 265卡塔尔(قطر‎;  // 设置窗体的标题Logo  Image image = new ImageIcon(“image//T83XSMYF}~B卡塔尔(قطر‎$$6}XYZ4KM3.png”卡塔尔.getImage(State of Qatar;  this.setIconImage(imageState of Qatar;  // 窗体大小无法校正  this.setResizable(false卡塔尔;  // 居中展现  this.setLocationRelativeTo(nullState of Qatar;  // 窗体可知  this.setVisible(true卡塔尔国;  }  /*  * 开头化方法  */  public void init(卡塔尔国 {  // 创造三个容器  Container con = this.getContentPane(卡塔尔(قطر‎;  jl1 = new JLabel(State of Qatar;  // 设置背景图片  Image image1 = new ImageIcon(“image//2BF5MB~_47SZRCV`SEL44OD.png”State of Qatar.getImage(卡塔尔国;  jl1.setIcon(new ImageIcon(image1State of Qatar卡塔尔;  jl1.setBounds(0, 0, 355, 265卡塔尔国;  // QQ登入头像设定  jl2 = new JLabel(卡塔尔国;  Image image2 = new ImageIcon(“image//D0PCQ~_MI}A1M9ZF8Z]M0T7.png”卡塔尔国.getImage(卡塔尔;  jl2.setIcon(new ImageIcon(image2卡塔尔卡塔尔;  jl2.setBounds(40, 95, 50, 60State of Qatar;  // 客户号码登录输入框  username = new JTextField(卡塔尔(قطر‎;  username.setBounds(100, 100, 150, 20卡塔尔;  // 客商号码登陆输入框旁边的文字  jl3 = new JLabel(“注册账号”卡塔尔;  jl3.setBounds(260, 100, 70, 20卡塔尔;  jl3.setForeground(Color.BLUE卡塔尔(قطر‎; // 密码输入框  password = new JPasswordField(卡塔尔;  password.setBounds(100, 130, 150, 20卡塔尔国;  // 密码输入框旁边的文字  jl4 = new JLabel(“找回密码”卡塔尔;  jl4.setBounds(260, 130, 70, 20卡塔尔国;  jl4.setForeground(Color.BLUE卡塔尔(قطر‎; // 输入框下方文字  jc1 = new JCheckBox(“记住密码”卡塔尔;  jc1.setBounds(105, 155, 80, 15卡塔尔;  jc2 = new JCheckBox(“自动登陆”State of Qatar;  jc2.setBounds(185, 155, 80, 15卡塔尔(قطر‎;  // 顾客登入状态选拔  jcb = new JComboBox(State of Qatar;  jcb.addItem(“在线”卡塔尔国;  jcb.addItem(“隐身”卡塔尔(قطر‎;  jcb.addItem(“离开”卡塔尔(قطر‎;  jcb.setBounds(40, 150, 55, 20卡塔尔国;  // 开关设定  bu1 = new JButton(“登入”卡塔尔;  bu1.setBounds(100, 175,150,30卡塔尔;  // 给开关增多1个事件  bu1.addActionListener(new ActionListener(卡塔尔(قطر‎ {  @Override  public void actionPerformed(ActionEvent e卡塔尔(قطر‎ {  String str=e.getActionCommand(State of Qatar;  if(“登陆”.equals(str卡塔尔State of Qatar{  String getName =username.getText(卡塔尔国;  // String getPwd =password.getText(卡塔尔(قطر‎;  String userpassword = new String(password.getPassword(卡塔尔(قطر‎卡塔尔; String sql =”secelt * from  while name='”username”‘and psw'”=userpassword'””; JOptionPane.showConfirmDialog(null,”您输入的客商名是”+getName卡塔尔国;  }  }  }卡塔尔国; jl1.add(jl2卡塔尔;  jl1.add(jl3State of Qatar;  jl1.add(jl4卡塔尔;  jl1.add(jc1卡塔尔(قطر‎;  jl1.add(jc2State of Qatar;  jl1.add(jcb卡塔尔;  jl1.add(bu1State of Qatar;  con.add(jl1State of Qatar;  con.add(username卡塔尔(قطر‎;  con.add(password);  }  public static void main(String[] argsState of Qatar {  // 实例化对象  GUIQQ qq = new GUIQQ(卡塔尔国;  }  }

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class JTextFieldDemo extends JFrame implements ActionListener{

AddDialog.this.setVisible;为啥那句改成ad.setVisible;
会报空指针非凡。

地点那句有错createStatement红线
Type mismatch: cannot convert from java.sql.Statement to
java.beans.Statement

    JTextField jtf=new
JTextField(10);
    JPasswordField jpf=new
JPassword菲尔德(10卡塔尔;//创制密码框
    JButton jb=new
JButton(“提交”卡塔尔国;//成立开关
    JLabel jl=new
JLabel(“客户名”卡塔尔国;//成立标签
    JLabel j2=new
JLabel(“密码”State of Qatar;//成立标签
    JLabel j3=new
JLabel(“等待你的登录!”卡塔尔国;//创造标签
    JPanel jp=new
JPanel(卡塔尔;//创立面板
    //定义结构器
    public JTextFieldDemo()
    {
        this.setTitle(“登录系统”卡塔尔;
        jp.setLayout(null卡塔尔国;//接受空构造
        jl.setBounds(30,20,80,30卡塔尔国;//设置标签1的职位和尺寸
        jp.add(jl);
        j2.setBounds(30,70,80,30卡塔尔国;//设置标签2的地点和大小
        jp.add(j2);
        jtf.setBounds(80,20,180,30卡塔尔国;//设置文本框的地方和分寸
        jp.add(jtf);
        jpf.setBounds(80,70,180,30卡塔尔国;//设置密码框的地点和大小
        jp.add(jpf);
        jb.setBounds(50,130,80,30卡塔尔;//设置按钮的岗位和分寸
        jp.add(jb);
        j3.setBounds(10,180,300,30State of Qatar;//设置标签3的岗位和尺寸
        jp.add(j3);
        jb.addActionListener(this卡塔尔;//为文本框注册监听器
        this.add(jpState of Qatar;//将面板增添到窗口中
        this.setBounds(300,250,300,300卡塔尔;//设置窗口的职位和分寸
        this.setVisible(true);
    }
    public void actionPerformed(ActionEvent e)
    {
        String s=jtf.getText(State of Qatar;//获取文本框的内容
        String s1=new
String(jpf.getPassword(State of Qatar卡塔尔;//获取密码框的内容
        if(s.equals(“java”)&&s1.equals(“1234”))
        {
            j3.setText(“登录成功!”卡塔尔;
        }
        else
        {
            j3.setText(“登入退步!”卡塔尔(قطر‎;
        }
    }
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        JTextFieldDemo f=new
JTextFieldDemo();
    }

 rs=s.executeQuery("select * from info where quanxian = '老师'");

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图