Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search Coderanch
Advance search
Google search
Register / Login
John Johnson
Greenhorn
+ Follow
1
Posts
1
Threads
0
Cows
since Oct 24, 2006
Merit badge:
grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
Ranch Hand Scavenger Hunt
Number Posts (1/100)
Number Threads Started (1/100)
Number Cows Received (0/5)
Number Likes Received (0/10)
Number Likes Granted (0/20)
Set bumper stickers in profile (0/3)
Report a post to the moderators (0/1)
Edit a wiki page (0/1)
Create a post with an image (0/2)
Greenhorn Scavenger Hunt
First Post
Number Posts (1/10)
Number Threads Started (1/10)
Number Likes Received (0/3)
Number Likes Granted (0/3)
Set bumper stickers in profile (0/1)
Set signature in profile
Search for a post/thread (0/3)
Set a watch on a thread
Save thread as a bookmark
Create a post with an image (0/1)
Recent posts by John Johnson
help arranging layout of TextField
I need to get the ID and Password TextFields to look like this:
ID: TEXTFIELD
Password: TEXTFIELD
import java.awt.*; import java.applet.*; import java.awt.event.*; public class PasswordApplet extends Applet implements ActionListener { //Declaring variables String id, password; boolean success; String idArray[ ]={"id", "Admin", "Student", "Guest"}; String passwordArray[ ]={"password", "ad06", "stud06", "gu06" }; //Create components for applet Label headerLabel = new Label("Please type your ID and Password"); Label idLabel = new Label("ID:"); TextField idField = new TextField(7); Label passwordLabel = new Label("Password:"); TextField passwordField = new TextField(7); Button loginButton = new Button("Login"); public void init() { //Set color, layout, and add components setBackground(Color.black); setForeground(Color.blue); setLayout(new FlowLayout(FlowLayout.LEFT,40,30)); add(headerLabel); add(idLabel); add(idField); idField.requestFocus(); add(passwordLabel); add(passwordField); passwordField.setEchoChar('*'); add(loginButton); loginButton.addActionListener(this); } public void actionPerformed(ActionEvent e) { //Assigning data id = idField.getText(); password = passwordField.getText(); success = false; //Sequential search for (int i=0; i<4; i++) { if ((idArray[i].compareTo(id)==0) && (passwordArray[i].compareTo(password)==0)) success=true; } if (success==true) {headerLabel.setText("Login Successful"); repaint(); } else { headerLabel.setText("Invalid. Try again."); idField.setText (""); passwordField.setText(""); idField.requestFocus(); } } }
show more
17 years ago
Swing / AWT / SWT