1,不一定吧!继承JFrame同样也是可以的,只要是界面化的都可以
4,给你的窗口添加窗口关闭事件:
   addWindowListener(new WindowAdapter() 
   {
      public void windowClosing(WindowEvent e) {
        System.exit(0);
      }
    });

解决方案 »

  1.   

    轻量级构件是透明,
    setOpaque(true);
      

  2.   

    import java.awt.*;
    import javax.swing.*;
    import com.borland.jbcl.layout.*;
    import javax.swing.border.*;
    import java.io.*;
    import java.util.*;
    import java.net.*;
    import java.awt.event.*;
    public class Login extends JDialog {
      JPanel panel1 = new JPanel();
      XYLayout xYLayout1 = new XYLayout();
      JPasswordField jPasswordField1 = new JPasswordField();
      TitledBorder titledBorder1;
      TitledBorder titledBorder2;
      JTextField jTextField1 = new JTextField();
      JButton jButton1 = new JButton();
      JLabel jLabel1 = new JLabel();
      JLabel jLabel2 = new JLabel();
      JButton jButton2 = new JButton();
      JLabel jLabel3 = new JLabel();
     
      public Login(Frame frame, String title, boolean modal) {
        super(frame, title, modal);
        try {
          jbInit();
          pack();
             }
        catch(Exception ex) {
          ex.printStackTrace();
        }
      }
      public static void main(String argv[]){
        try {
          new Login(null, "登录", false).show();
        } catch(Exception e) {
          e.printStackTrace();
        }
      }  private void jbInit() throws Exception {
        titledBorder1 = new TitledBorder("");
        titledBorder2 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white,new Color(134, 134, 134)),"");
        panel1.setLayout(xYLayout1);
        panel1.setOpaque(true);
        jPasswordField1.setFont(new java.awt.Font("Dialog", 0, 15));
        jPasswordField1.setText("jPasswordField1");
        panel1.setBorder(titledBorder1);
        jTextField1.setFont(new java.awt.Font("Dialog", 0, 15));
        jTextField1.setText("TEST");
        jButton1.setFont(new java.awt.Font("Dialog", 0, 15));
        jButton1.setText("登    录");    addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });    
        jLabel1.setFont(new java.awt.Font("Dialog", 0, 16));
        jLabel1.setText("密    码");
        jLabel2.setFont(new java.awt.Font("Dialog", 0, 16));
        jLabel2.setText("用户名");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });
        jButton2.setText("退    出");
        jButton2.setFont(new java.awt.Font("Dialog", 0, 15));
        jLabel3.setFont(new java.awt.Font("Serif", 0, 16));
        jLabel3.setForeground(UIManager.getColor("InternalFrame.activeTitleGradient"));
        
        this.getContentPane().add(panel1, BorderLayout.CENTER);
        setBounds(150,150,500,500);  //用这一句可以控制屏幕左上角位置,但控制不了大小
        panel1.add(jLabel3,      new XYConstraints(71, 35, 247, 31));
        panel1.add(jTextField1, new XYConstraints(168, 105, 111, 27));
        panel1.add(jLabel2, new XYConstraints(108, 108, 56, -1));
        panel1.add(jPasswordField1, new XYConstraints(168, 168, 109, 28));
        panel1.add(jLabel1, new XYConstraints(108, 170, 56, -1));
        panel1.add(jButton2, new XYConstraints(210, 243, 136, -1));
        panel1.add(jButton1, new XYConstraints(37, 245, 136, -1));
      }}
      

  3.   

    对JDialog来说关闭用JDialog.dispose(); JDialog做个登录界面足够了,控制屏幕左上角位置用setLocation()方法,控制大小setSize();方法。建议你在使用组件时多看看它都有些什么方法可用。学着用布局管理器来做