100分求 是很简单,可我能力较差,以前只用Jbuilder没用过jdk 谢谢帮助了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用jbuilder就更简单了。自己搞一搞吧。 啥叫用过JB,没有用过JDK???HOHO~~~@.@||~ 以前一直用Jbuilder,不知道jdk是什么? 嗯,用过jb就是通过jdk来实现的 是很简单,可我能力较差,以前只用Jbuilder没用过jdk 谢谢帮助了晕死,果然是只会鼠标拖拖拖,notepad却不会使 你先用JB作拖出界面,自动生成的代码就是用的JDK了:)点击确定后写文件:FileWriter writer;writer = new FileWriter("LOGIN.TXT");writer.write(username+"\r\n");writer.write(pwd+"\r\n");writer.flush();writer.close(); 那我用比较类似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); } }} 谢谢各位那天下午很是需要,现在不用了。但仍感谢各位了!此帖已结happyegg:15;yigeyigeyige,nwpulipeng,oyljerry,hongyan2004:10;hongyan2004,xu_xinyu,midthinker,bestdelphier,kypfos,garry2000,relive,apollo333,F1in2003:5; 推荐一本包含1.6特性的的Java Swing的书吧! 右键弹出菜单不会用,请求帮助 请教实现方法:写一个服务程序,从socket读数据并写到数据库表里面去 求助!!!!急!!! java如何显示矢量图? 请问大家在java中的事务是怎样解决的。 出错信息是在语句Folder.*=...下面有一个小箭头,是什么意思?不能调用folder? 文件流问题 熟悉JDK1.3自带例子的请进 问一个rmi的问题 resin 中怎么停止已经启动的线程? [求助] 如何影响父类的流程但不重写它?
HOHO~~~
@.@||~
没用过jdk 谢谢帮助了晕死,果然是只会鼠标拖拖拖,notepad却不会使
点击确定后写文件:
FileWriter writer;
writer = new FileWriter("LOGIN.TXT");
writer.write(username+"\r\n");
writer.write(pwd+"\r\n");
writer.flush();
writer.close();
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);
}
}}
那天下午很是需要,现在不用了。但仍感谢各位了!
此帖已结happyegg:15;
yigeyigeyige,nwpulipeng,oyljerry,hongyan2004:10;
hongyan2004,xu_xinyu,midthinker,bestdelphier,kypfos,garry2000,relive,apollo333,F1in2003:5;