import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing. *;
class zhujiemian {
JFrame JJ = new JFrame ();
JPanel JP = new JPanel ();
JTextField JT1, JT2;
public void zong () {
JJ.setVisible (true);
JJ.add (JP);
JJ.setTitle ("QQ login program " ) ;
JJ.setSize (500,300);
JJ.setLocation (200,100);
}
public void denglu () {
JP.setLayout (null);
JButton JB1 = new JButton (" Login " ) ;
JButton JB2 = new JButton (" Exit" ) ;
JB1.setBounds (100,150,90,28);
JB2.setBounds (300,150,90,28);
JP.add (JB1);
JP.add (JB2);
JB1.addMouseListener (new JB1Listener ());
JB2.addMouseListener (new JB1Listener ());
}
class JB1Listener implements MouseListener {
public void mouseReleased (MouseEvent e) {
JFrame JF = new JFrame ();
JF.setVisible (true);
JF.setTitle ("QQ login program " ) ;
JF.setSize (200,400);
JF.setLocation (1150,30);
JJ.setVisible (false);
JPanel JP = new JPanel ();
JF.add (JP);
JP.setLayout (null);
JButton jb1 = new JButton (" Space " ) ;
jb1.setBounds (80,60,30,28);
JP.add (jb1);
JButton jb2 = new JButton (" microblogging" ) ;
jb2.setBounds (130,60,30,28);
JP.add (jb2);
JLabel jb = new JLabel (" Weiyang missing " ) ;
jb.setBounds (90,0,70,70);
JP.add (jb);
}
public void mouseClicked (MouseEvent e) {
/ / TODO Auto-generated method stub
}
public void mouseEntered (MouseEvent e) {
/ / TODO Auto-generated method stub
}
public void mouseExited (MouseEvent e) {
/ / TODO Auto-generated method stub
}
@ Override
public void mousePressed (MouseEvent e) {
/ / TODO Auto-generated method stub
}
}
class JB2Listener implements MouseListener {
public void mouseReleased (MouseEvent e) {
System.exit (0);
}
public void mouseClicked (MouseEvent e) {
/ / TODO Auto-generated method stub
}
public void mouseEntered (MouseEvent e) {
/ / TODO Auto-generated method stub
}
public void mouseExited (MouseEvent e) {
/ / TODO Auto-generated method stub
}
@ Override
public void mousePressed (MouseEvent e) {
/ / TODO Auto-generated method stub
}
}
public void Label () {
JLabel JL1 = new JLabel ("QQ number" ) ;
JL1.setBounds (100,28,50,50);
JT1 = new JTextField (10);
JT1.setBounds (165,40,150,25);
JLabel JL2 = new JLabel (" password " ) ;
JL2.setBounds (100,68,50,50);
JT2 = new JTextField (10);
JT2.setBounds (165,80,150,25);
JP.add (JL1);
JP.add (JL2);
JP.add (JT1);
JP.add (JT2);
}
public int panduan () {
JT1.getText ();
return 1;
}
public static void main (String args []) {
zhujiemian z = new zhujiemian ();
z.Label ();
z.zong ();
z.denglu ();
int i;
i = z.panduan ();
}
}
like running, for QQ number and password match. If it is correct , then execute the event log . However, I think for a long time could not think , if not wrong, then how to display the login event it ? Log events and interfaces are connected together . Can not think , seeking master Weapon, the algorithm uses the text to break out on the line, and then I'll get their own code . Thank you ! ! ! ! ! !
------ Solution ---------------------------------------- ----
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.*;
class zhujiemian {
JFrame JJ=new JFrame();
JPanel JP=new JPanel();
JTextField JT1, JT2;
public void zong() {
JJ.setVisible(true);
JJ.add(JP);
JJ.setTitle("QQ登录程序");
JJ.setSize(500,300);
JJ.setLocation(200,100);
}
public void denglu() {
JP.setLayout(null);
JButton JB1=new JButton("登录");
JButton JB2=new JButton("退出");
JB1.setBounds(100,150,90,28);
JB2.setBounds(300,150,90,28);
JP.add(JB1);
JP.add(JB2);
JB1.addMouseListener(new JB1Listener());
JB2.addMouseListener(new JB1Listener());
}
class JB1Listener implements MouseListener {
public void mouseReleased(MouseEvent e) {
//如果匹配,才显示新的窗口
if (JT1.getText().equals("name")&&JT2.getText().equals("pw")) {
JFrame JF=new JFrame();
JF.setVisible(true);
JF.setTitle("QQ登录程序");
JF.setSize(200,400);
JF.setLocation(1150,30);
JJ.setVisible(false);
JPanel JP=new JPanel();
JF.add(JP);
JP.setLayout(null);
JButton jb1=new JButton("空间 ");
jb1.setBounds(80,60,30,28);
JP.add(jb1);
JButton jb2=new JButton("微博 ");
jb2.setBounds(130,60,30,28);
JP.add(jb2);
JLabel jb=new JLabel("未央不见");
jb.setBounds(90,0,70,70);
JP.add(jb);
}
}
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
}
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
}
class JB2Listener implements MouseListener {
public void mouseReleased(MouseEvent e) {
System.exit(0);
}
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
}
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
}
public void Label() {
JLabel JL1=new JLabel("QQ号码");
JL1.setBounds(100,28,50,50);
JT1=new JTextField(10);
JT1.setBounds(165,40,150,25);
JLabel JL2=new JLabel(" 密码");
JL2.setBounds(100,68,50,50);
JT2=new JTextField(10);
JT2.setBounds(165,80,150,25);
JP.add(JL1);
JP.add(JL2);
JP.add(JT1);
JP.add(JT2);
}
public int panduan() {
JT1.getText();
return 1;
}
public static void main(String args[]) {
zhujiemian z=new zhujiemian();
z.Label();
z.zong();
z.denglu();
int i;
i=z.panduan();
}
}
------ For reference only ---------------------------- -----------
upstairs god T-MAC can leave your QQ number you
------ For reference only ------ ---------------------------------
year round on Q, leaving no avail. I am also very like Roy
没有评论:
发表评论