Search code examples
javaswingframejtextfield

Java - How to make a Jtextfield fill the whole frame


I'm trying to make a JTextArea fill the whole frame so it looks somewhat like notepad or textedit. Also would it be possible to have a scroll pane. Thanks in advance! Edit : JTextArea


Solution

  • Try this---

    import java.awt.BorderLayout;
    
    import javax.swing.JFrame;
    import javax.swing.JTextField;
    
    
    public class TextFieldTest {
        public static void main(String[] args) {
            JFrame f = new JFrame();
            f.setLayout(new BorderLayout());
            JTextField tf = new JTextField();
            f.getContentPane().add(BorderLayout.EAST, tf);
            f.pack();
            f.setVisible(true);
        }
    }