Mình có một package java như sau:
Mã:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package testawt;
import java.awt.Button;
import java.awt.Checkbox;
import java.awt.CheckboxGroup;
import java.awt.FlowLayout;
import java.awt.Label;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
/**
*
* @author Admin
*/
public class myframe extends JFrame implements ActionListener {
Label stinfo = new Label("Student Infomation");
Label hr = new Label("__________________________________");
Label fullname = new Label("Full Name ");
Label sex = new Label("Sex ");
Label lang = new Label("Language ");
Label email = new Label("Email ");
TextField txt1 = new TextField(20);
TextField txt2 = new TextField(20);
CheckboxGroup radio = new CheckboxGroup();
Checkbox r1 = new Checkbox("Nam", radio, true);
Checkbox r2 = new Checkbox("Nu ", radio, false);
Checkbox c1 = new Checkbox("English", false);
Checkbox c2 = new Checkbox("VietNam", true);
Checkbox c3 = new Checkbox("Lao", false);
Button btinfo = new Button("Print Info");
Button btcan = new Button("Cancel");
public myframe(String title) {
super(title);
setLayout(new FlowLayout());
this.add(stinfo);
this.add(hr);
this.add(fullname);
this.add(txt1);
this.add(sex);
this.add(r1);
this.add(r2);
this.add(lang);
this.add(c1);
this.add(c2);
this.add(c3);
this.add(email);
this.add(txt2);
this.add(btinfo);
this.add(btcan);
}
public static void main(String[] args) {
myframe e1 = new myframe("Student Infomation - TuanVA");
e1.setVisible(true);
e1.setSize(300, 250);
}
public void actionPerformed(ActionEvent e) {
}
}
}
Khi nhấn vào button PrintInfo
Nếu Full name chưa nhập thì hiện ra message chưa nhập tên
nếu nhập số yêu cầu nhập lại
Tương tự vs email
yêu cầu email phải nhập đúng định dạng
Nếu đã nhập đủ thì hiện ra một message hiểm thị tất cả các thông tin về name, sex, language, email
Nhấn vào button cancel thì thoát khỏi chương trình
Rất mong các bạn giúp mình đưa ra hướng giải quyết đối với bài tập trên.
Xe nâng người Boom lift được Công Ty TNHH Trung thành phân phối chính hãng tại khu vực phía Bắc. Với chi phí đầu tư ban đầu thấp hơn rất nhiều so với các loại xe nâng dầu , xe nâng động cơ loại...
Xe nâng người được trung thành nhập khẩu giá tốt