是很简单,可我能力较差,以前只用Jbuilder
没用过jdk 谢谢帮助了

解决方案 »

  1.   

    用jbuilder就更简单了。自己搞一搞吧。
      

  2.   

    啥叫用过JB,没有用过JDK???
    HOHO~~~
    @.@||~
      

  3.   

    以前一直用Jbuilder,不知道jdk是什么?
      

  4.   

    嗯,用过jb就是通过jdk来实现的
      

  5.   

    是很简单,可我能力较差,以前只用Jbuilder
    没用过jdk 谢谢帮助了晕死,果然是只会鼠标拖拖拖,notepad却不会使
      

  6.   

    你先用JB作拖出界面,自动生成的代码就是用的JDK了:)
    点击确定后写文件:
    FileWriter writer;
    writer = new FileWriter("LOGIN.TXT");
    writer.write(username+"\r\n");
    writer.write(pwd+"\r\n");
    writer.flush();
    writer.close();
      

  7.   

    那我用比较类似jbuilder的jdk帮你写一个吧import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.io.File;
    import java.util.Properties;
    import java.io.FileOutputStream;public class Logon extends JFrame {
    JLabel jLabel1 = new JLabel();
    JTextField txtId = new JTextField();
    JLabel jLabel2 = new JLabel();
    JTextField txtPassword = new JTextField();
    JButton btnOk = new JButton();
    JButton btnCancel = new JButton();
    public Logon() {
    try {
    jbInit();
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    private void jbInit() throws Exception {
    jLabel1.setText("Name");
    jLabel1.setBounds(new Rectangle(31, 35, 62, 16));
    this.getContentPane().setLayout(null);
    txtId.setText("");
    txtId.setBounds(new Rectangle(114, 33, 116, 22));
    jLabel2.setText("Password");
    jLabel2.setBounds(new Rectangle(31, 79, 62, 16));
    txtPassword.setText("");
    txtPassword.setBounds(new Rectangle(114, 78, 117, 22));
    btnOk.setBounds(new Rectangle(35, 137, 73, 25));
    btnOk.setText("Go");
    btnOk.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e) {
    btnOk_actionPerformed(e);
    }
    });
    btnCancel.setBounds(new Rectangle(134, 138, 73, 25));
    btnCancel.setText("Cancel");
    btnCancel.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e) {
    btnCancel_actionPerformed(e);
    }
    });
    this.getContentPane().add(txtId, null);
    this.getContentPane().add(jLabel1, null);
    this.getContentPane().add(jLabel2, null);
    this.getContentPane().add(txtPassword, null);
    this.getContentPane().add(btnOk, null);
    this.getContentPane().add(btnCancel, null);
    }
    void btnOk_actionPerformed(ActionEvent e) {
    String id = this.txtId.getText();
    String passwd = this.txtPassword.getText();
    if(id.trim().length()==0 || passwd.trim().length()==0) {
    JOptionPane.showMessageDialog(this, "Id and password should not be blank", "Error", JOptionPane.ERROR_MESSAGE);
    return;
    }
    File rootFile = new File(".");
    String systemPath = rootFile.getAbsolutePath();
    systemPath = systemPath.substring(0, systemPath.length() - 1);
    String propFileName = systemPath + "LOGIN.TXT";
    Properties cfg = new Properties();
    cfg.put("USER_NAME", id);
    cfg.put("PASSWORD", passwd);
    try {
    cfg.store(new FileOutputStream(propFileName), "");
    JOptionPane.showMessageDialog(this, "Info are saved to : " + propFileName, "Ok", JOptionPane.ERROR_MESSAGE);
    } catch (Exception ex) {
    JOptionPane.showMessageDialog(this, ex, "Error", JOptionPane.ERROR_MESSAGE);
    } }
    void btnCancel_actionPerformed(ActionEvent e) {
    this.dispose();
    }
    public static void main(String[] args) {
    try {
    int dialogWidth = 280;
    int dialogheight = 200;
    Logon dlg = new Logon();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    dlg.setLocation(screenSize.width / 2 - dialogWidth / 2, screenSize.height / 2 - dialogheight / 2);
    dlg.setSize(dialogWidth, dialogheight);
    dlg.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    }
    });
    dlg.show();
    } catch (Exception e) {
    System.out.println("[Main] Exception : " + e);
    }
    }}
      

  8.   

    谢谢各位
    那天下午很是需要,现在不用了。但仍感谢各位了!
    此帖已结happyegg:15;
    yigeyigeyige,nwpulipeng,oyljerry,hongyan2004:10;
    hongyan2004,xu_xinyu,midthinker,bestdelphier,kypfos,garry2000,relive,apollo333,F1in2003:5;