• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

layout manager question

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When in doubt, go to the API JavaDocs
TextField has a constructor that takes the number of columns.
Junilu
 
Jade Davidson
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cool, thanks.
 
Being a smart alec beats the alternative. This tiny ad knows what I'm talking about:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic