1. 程式人生 > >java中窗體的轉化

java中窗體的轉化

clas per size todo one over nbsp 方法 java

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

public class AA implements ActionListener{
    JFrame f;
    JPanel p;
    JButton b;
    JLabel l;
    JTextField t1;
    JTextField t2;
    public AA(){
        f 
= new JFrame(); p = new JPanel(); l = new JLabel(); t1 = new JTextField(10); t2 = new JTextField(10); b = new JButton("賬號:"); p.add(b); p.add(t1); b = new JButton("密碼:"); p.add(b); p.add(t2); b = new JButton("登錄"); f.add(p); p.add(b); f.setSize(
450,400); b.addActionListener(this); f.setVisible(true); } public static void main(String[] args) { // TODO 自動生成的方法存根 new AA(); } @Override public void actionPerformed(ActionEvent arg0) { // TODO 自動生成的方法存根 f.setVisible(false
); JFrame f1; JPanel p1; JButton b1; f1 = new JFrame(); p1 = new JPanel(); b1 = new JButton("登錄成功"); f1.add(p1); p1.add(b1); f1.setSize(400, 400); p1.setBackground(Color.pink); f1.setVisible(true); } }

java中窗體的轉化