보안상의 이유로 로그인 한 창에서 사용자 ID (기본값)를 설정해야하는데 전혀 모르겠습니다. 여기에 내 코드가 있습니다.
import javax.swing.*;
import java.awt.event.*;
public class PasswordFieldExample {
public static void main(String[] args) {
JFrame f=new JFrame("User-ID");
final JLabel label = new JLabel();
label.setBounds(20,150, 200,50);
JLabel l1=new JLabel("User-Id:");
l1.setBounds(20,20, 80,30);
JButton b = new JButton("Login");
b.setBounds(100,120, 80,30);
final JTextField text = new JTextField(12); text.setText(System.getProperty("user.name")); text.setBounds(100, 20, 100, 30);
f.add(l1); f.add(label); f.add(b); f.add(text);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
/** b.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// String data = "Username " + text.getText();
// label.setText(data);
// }
}); */
}
}
System.getProperty("user.name");
기본 계정 이름으로 Java 사용
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다