Text in field objects go out of bounds..
I'm writing a custom notepad as a challenge for some youngsters. I need a text field so the user can write their data into. For some reason, when I try to go out of bounds or hit the button "Enter" the text will keep going, and will never create a new line.
Here is the code. I have tried setting bounds, but it does not work.
Code :
private JComponent textField() {
JComponent text = new JPanel();
TextField field = new TextField();
text.add(field);
text.setLayout(new GridLayout(1, 1));
return text;
}
Re: Text in field objects go out of bounds..
First, I would not recommend combining AWT and swing...if you need a text field, use the swing equivalent JTextField. Second, a JTextField (or TextField) does not support multi-line text. If you want several lines, use a JTextArea, JTextPane, or JEditorPane.
Re: Text in field objects go out of bounds..
Quote:
Originally Posted by
copeg
First, I would not recommend combining AWT and swing...if you need a text field, use the swing equivalent JTextField. Second, a JTextField (or TextField) does not support multi-line text. If you want several lines, use a JTextArea, JTextPane, or JEditorPane.
Thank you very much, I did not know that. I just could not remember the name of the class which handled that.