dcsimg
Newbie needs help with Text Fields
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   guybrush_threepwood
Posted On:   Saturday, December 7, 2002 03:34 PM

How do I set the position of a text field without SWING? I tried .setBounds(a, b, c, d), but it still displays a text field in the center... can anyone give me a sample?

Re: Newbie needs help with Text Fields

Posted By:   eimi_nos  
Posted On:   Sunday, December 8, 2002 02:51 AM

You can use implementing classes of java.awt.LayoutManager, java.awt.LayoutManager2.
For example:

import java.awt.*;
import java.awt.event.*;

class TestFrame extends Frame {
private TextField tf;
private Button bt;
public TestFrame() {
setSize(200,80);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
add(tf=new TextField("blank"),BorderLayout.NORTH);//These are points for your question
add(bt=new Button("Button"),BorderLayout.SOUTH);//
bt.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
tf.setText("TextField");
}
});
}
}
public class TestAWT {
public static void main(String[] args) {
Frame w=new TestFrame();
w.setVisible(true);
}
}



About | Sitemap | Contact