一个登陆窗口的java程序,如何嵌入到HTML中。实现网页中的登陆
程序是这样的:
------------------------
//====登陆窗口======
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class LoginDialogDemo extends JFrame{
JButton button= new JButton( "Click Me ");
JPanel panel = new JPanel(new FlowLayout());
public LoginDialogDemo(){
final JFrame frame= this;
this.getContentPane().add(panel,BorderLayout.SOUTH);
panel.add(button);
button.addActionListener(new ActionListener(){
public void actionPerformed (ActionEvent e){
showLoginDialog(frame);
}
});
this.setSize(300, 200);
this.setTitle( "显示登陆对话框 ");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.show();
}
void showLoginDialog(JFrame frame){
JPanel p = new JPanel (new GridLayout(0,1));
JTextField tfUserName = new JTextField();
JPasswordField tfPassword = new JPasswordField();
p.add(new JLabel ( "Username: "));
p.add(tfUserName);
p.add(new JLabel ( "Password: "));
p.add(tfPassword);
if (JOptionPane.showConfirmDialog(frame,
p,
"Login ",
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE)
== JOptionPane.OK_OPTION){
System.out.println( "User Name: "+tfUserName.getText());
System.out.println( "Password: "+ new String (tfPassword.getPassword()));
}
}
public static void main(String[] args){
LoginDialogDemo frame = new LoginDialogDemo();
}
}
-----------------------------------------
请问,如何让这个程序在一个WEB页面中,单击登陆后实现登陆呢?这个不是APPLET,我不知道改怎么弄。
------解决方案--------------------改成 applet ,继承 Applet,重写 几个方法
------解决方案--------------------jsf