This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes layout manager question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "layout manager question" Watch "layout manager question" New topic

layout manager question

Jade Davidson
Ranch Hand

Joined: Oct 12, 2001
Posts: 64
I am still working on my applet. It is looking better, except I am having this one weird problem. I am trying to get two textfields for user input to display on the same line at the top of the browser window. The code I have makes them display as two small boxes. How do I make them longer? I don't know if this is a question of using the right layout manager, or what. Any input would be helpful. I am holding off on coding the action event methods until I can get the GUI to look somewhat presentable.
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
public class NumerologyApplet extends Applet

implements ActionListener {
//Declare the textfields for input
private TextField dateInput = new TextField("");
private TextField nameInput = new TextField("");
private TextArea results = new TextArea("");
//Declare buttons
private Button closeBtn = new Button("Close");
private Button compBtn = new Button("Compute");
private Button refBtn = new Button("Refresh");
//Declare panels

Panel xPanel = new Panel();
Panel yPanel = new Panel();
Panel zPanel = new Panel();
Panel buttonPanel = new Panel();
public void init() {
//Make sure textfield background is white
//Add textfields to panels

//Set layout for panels

//Add buttons to button panel
//Add the panels
public void actionPerformed(ActionEvent event) {
Junilu Lacar

Joined: Feb 26, 2001
Posts: 4445

When in doubt, go to the API JavaDocs
TextField has a constructor that takes the number of columns.

Junilu - [How to Ask Questions] [How to Answer Questions]
Jade Davidson
Ranch Hand

Joined: Oct 12, 2001
Posts: 64
Cool, thanks.
I agree. Here's the link:
subject: layout manager question
Similar Threads using a component Array and Counter-Controlled Loop
why am I getting a null pointer exception when I run this?
grid bag panels overlap : please HELP if you can
applet question