package yingyong; import javax.swing.JPanel; import java.util.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class my extends JPanel{

hundredcarriageΛογισμικό & κατασκευή λογ/κού

3 Νοε 2013 (πριν από 3 χρόνια και 5 μήνες)

175 εμφανίσεις

package

yingyong;


import

javax.swing.JPanel;

import

java.util.*;

import

java.awt.*;

import

java.awt.event.*;

import

javax.swing.*;

public

class

my

extends

JPanel{



private

JButton

push,pa;


private

JLabel

label,ll;


private

JPasswordField

h;


private

JTextField

f;





public

my()

{










setBackground(Color.white);










ll

=

new

JLabel("username");









push

=

new

JButton("ok");










f=new

JTextField(10);










h=new

JPasswordField(10);









push.addActionListener(new

Buttonlistener
());









pa=new

JButton("Reset");










pa.addActionListener(new

passlistener());










label

=

new

JLabel("

password

");









add(ll);









add(f);









add(label);









add(h);









add(push);









add(pa);









setPreferre
dSize(new

Dimension(200,

200));






}






private

class

Buttonlistener

implements

ActionListener

{










public

void

actionPerformed(ActionEvent

e)

{












String

name="
臧琦
";












String

pass="110701
13
";











String

pa=
String.copyValueOf(h.getPassword());













if(name.equals(f.getText())

&&pass.equals(pa
))


















JOptionPane.showMessageDialog(label
,"Welcom"

);















else


















JOptionPane.showMessageDialog(label
,"usrname/password

eorr"

);












}




















}





private

class


passlistener

implements

ActionListener

{










public

void

actionPerformed(ActionEvent

e)

{













f.setText("");













h.setText("");









}


}

}


import

java.awt.BorderLayout;

impo
rt

javax.swing.JFrame;

import

java.awt.*;

import

java.awt.event.*;

import

javax.swing.*;

public

class

Yingyong

{





public

static

void

main(String[]

args)

{
















JFrame

frame=new

JFrame

("JFrame


用举例
");











frame.setDefaultCloseOperation(J
Frame.DISPOSE_ON_
CLOSE);










frame.getContentPane().add(new

my());











frame.pack();













frame.setVisible(true);







}}