aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes quick gui question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "quick gui question" Watch "quick gui question" New topic
Author

quick gui question

Mike Brown
Greenhorn

Joined: Oct 19, 2003
Posts: 25
Hi, just a quick question, why dont all of my components show up on this form? After I get the rest of the components to show up I need to take the input from all of the textboxes and paint the results. I can get the text and put it together in a string but I was wondering, do you suggenst that I make this in two panels. One for the labels and text fields and one for the area I intend to paint with the drawString() method? I guess I am asking this because in one of my previous posts someone told me to be sure that I know where I am painting to. I was just wondering what is the best way to control this. I do know how to locate the graphics object with x, y. See how I can turn one question into two? Thanks everyone for your help. Im enjoying learning this stuff. Here is the code for the labels and text boxes. For some reason only the top two are showing up when I run it.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class MyForm extends JApplet //implements ActionListener
{
JLabel fName = new JLabel("First Name");
JTextField fText = new JTextField("",12);
JLabel lName = new JLabel("Last Name");
JTextField lText = new JTextField("",12);
JLabel lblEmail = new JLabel("Email");
JTextField eTxt = new JTextField("",12);

FlowLayout flow = new FlowLayout();
public void init()
{
Container con = getContentPane();
con.setLayout(flow);
con.add(fName);
con.add(fText);
con.add(lName);
con.add(lText);
con.add(lblEmail);
con.add(eTxt);
}
}
VIJAY Yadlapati
Ranch Hand

Joined: Aug 04, 2003
Posts: 175
Hi Mike,
With your code, I am can view all the components you have added to the applet.
If you want to display the information in the textfields on the applet, it would be better using a Label, and use setText() on that Label.
It would be better not to implement the paint() method, because it would degrade the performance.
Mike Brown
Greenhorn

Joined: Oct 19, 2003
Posts: 25
Thanks for the reply vijay!
Why is it that no matter what I did last night I could only see the top two items on my applet and not the other four. I tried recompiling it twice. Thats strange. BTW the reason I want to use the paint() method is only because that is what is specified in the assignment that I am curently working on. Do you have any suggestions?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: quick gui question