我的代码创建了一个基本的注册屏幕,但在JTextArea
objTE1
您选择文本所在的位置之前不会显示。
import java.awt.*;
import javax.swing.*;
public class SignUpScreen extends Frame
{
SignUpScreen()
{
super("No Layout Manager");
setLayout(null);
setTitle("Sign Up");
setSize(400,700);
show();
}
public static void main(String[] args)
{
Frame objFrame;
JTextArea objTE1;
JCheckBox objCheckMail;
JCheckBox objCheckEmail;
JCheckBox objCheckPhone;
Button objButtonFinish;
Button objButtonCancel;
TextField objEnterEmail;
TextField objEnterAdress;
TextField objEnterPhone;
TextField objEnterUsername;
TextField objEnterPassword;
TextField objConfirmPassword;
objFrame = new SignUpScreen();
objTE1 = new JTextArea();
objCheckMail = new JCheckBox("Mail Notifications");
objCheckEmail = new JCheckBox("Email Notifications");
objCheckPhone = new JCheckBox("Text Notifications");
objButtonFinish = new Button("Sign Up");
objButtonCancel = new Button("Cancel");
objEnterEmail = new TextField("Enter Email",0);
objEnterAdress = new TextField("Enter Adress",0);
objEnterPhone = new TextField("Enter Phone Number",0);
objEnterUsername = new TextField("Enter Username",0);
objEnterPassword = new TextField("Enter Password",0);
objConfirmPassword = new TextField("Confirm Password",0);
Font pagehead = new Font("Verdana", Font.BOLD, 24);
objTE1.setFont(pagehead);
objTE1.setForeground(Color.BLUE);
objTE1.setText(" Sign up for the\nWatermelone Mail List");
objTE1.setEditable(false);
objTE1.setVisible(true);
objTE1.setBounds(50, 75, 300, 70);
objCheckMail.setBounds(100,450,200,50);
objCheckEmail.setBounds(100,500,200,50);
objCheckPhone.setBounds(100,550,200,50);
objEnterEmail.setBounds(100,150,150,20);
objEnterAdress.setBounds(100,200,200,20);
objEnterPhone.setBounds(100,250,200,20);
objEnterUsername.setBounds(100,300,200,20);
objEnterPassword.setBounds(100,350,200,20);
objConfirmPassword.setBounds(100,400,200,20);
objButtonFinish.setBounds(50,600,120,60);
objButtonCancel.setBounds(220,600,120,60);
objFrame.add(objTE1);
objFrame.add(objEnterEmail);
objFrame.add(objButtonFinish);
objFrame.add(objButtonCancel);
objFrame.add(objEnterUsername);
objFrame.add(objEnterPassword);
objFrame.add(objConfirmPassword);
objFrame.add(objEnterAdress);
objFrame.add(objEnterPhone);
objFrame.add(objCheckMail);
objFrame.add(objCheckPhone);
objFrame.add(objCheckEmail);
}
}