aspose file tools*
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "layout manager question" Watch "layout manager question" New topic
Author

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.
<code>
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
dateInput.setBackground(Color.white);
nameInput.setBackground(Color.white);
//Add textfields to panels

xPanel.add(dateInput);
yPanel.add(nameInput);
zPanel.add(results);
//Set layout for panels


//Add buttons to button panel
closeBtn.addActionListener(this);
buttonPanel.add(closeBtn);
compBtn.addActionListener(this);
buttonPanel.add(compBtn);
refBtn.addActionListener(this);
buttonPanel.add(refBtn);
//Add the panels
add(xPanel);
add(yPanel);
add(zPanel);
add(buttonPanel);
}
public void actionPerformed(ActionEvent event) {
}
}
</code>
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4462
    
    6

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


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: http://aspose.com/file-tools
 
subject: layout manager question