java登录界面

来源:互联网 发布:单片机使用教程 编辑:程序博客网 时间:2024/06/06 01:15
import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;


public class Enter extends JFrame
{Frame f;
 private  JTextField text=new JTextField();
 private JPasswordField txt=new JPasswordField();
 private JButton but1=new JButton("登陆");
 private JButton but2=new JButton("注册");
private JButton but3=new JButton("退出");
 private static ImageIcon imgIcon=new ImageIcon("enter.jpg");
  private static Image img=imgIcon.getImage(); 
  
  public Enter(String title){
    super (title);
   BPanel jp=new BPanel();
   jp.setVisible(true); //设置面板可见、不透明
   jp.setOpaque(false); 




 setLayout(null);
 but1.setBounds(115,130,60,35);
 text.setBounds(115,50,200,25);
 txt.setBounds(115,85,200,25);
 but2.setBounds(220,135,80,30);
 but3.setBounds(280,180,100,25);
 jp.setBounds(0,0,400,350);
 this.getContentPane().add(text);
 this.getContentPane().add(txt);
 this.getContentPane().add(but1);
 this.getContentPane().add(but2);
 this.getContentPane().add(but3);
 this.getContentPane().add(jp);
   }
  static class BPanel extends JPanel{//定义方法BPanel
protected void paintComponent(Graphics g){
super.paintComponent(g);  
g.drawImage(img,0,0,this); }//在面板中画图
}
public static void main(String args[]){
  Enter en=new Enter("登陆");
  en.setSize(400,250);
  en.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  en.setVisible(true);

     }

}

PS : 新手上路