Reputation: 145
My code creates a basic Sign Up screen, but the JTextArea
objTE1
does not show up until you select where the text would be.
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);
}
}
Upvotes: 0
Views: 606
Reputation: 324118
new JTextArea(5, 30);
when creating a text area. That is specify the rows/columns for the text area.show()
. The proper method is setVisible(true)
Event Dispatch Thread (EDT)
.setVisible(true)
needs to be done AFTER all the components have been added to the frame.I suggest you read the section from the Swing tutorial on Using Layout Managers for some examples of using layout managers and on to use the EDT
.
Upvotes: 5