Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2012
    Thanked 0 Times in 0 Posts

    Formating a JTextField

    Hi again.

    I'm creating a form, which uses JTextFields to enter and store text.

    The problem is, I create a large JTextField, which has room to store about 4 lines of text. But the text doesn't take advantage of the room. The text is created in the center-left of the text box, and fills along horizantally. When it reaches the end, it keeps going off the side of the JTextField.

    What I WANT it do to is behave like any text-entry box on the internet- like the ones on this forum, where it starts in the top-left, and when it reaches the other side, it drops down a line.

    Any idea how to do this?

     JTextField bob = new JTextField("");  
     bob.setPreferredSize(new Dimension(300,20));
    c5.gridx = 1; c5.gridy = (i*3+0); p.add(bob, c5);

  2. #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Saskatoon, Saskatchewan
    Thanked 2,668 Times in 2,637 Posts
    I guess this depends on what you are comparing to. There are two major text input components in HTML, one is the text input type which is similar to the JTextField, and the other is the textarea which is similar to the JTextArea/JEditorPane/JTextPane.
    Methinks you are intending to make use of a multiline input such as the JTextArea. If you want it to be styleable, its easiest to use the JEditorPane.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts