package pkg1;

import java.awt.*;
import javax.swing.*;

public class Main {

    public static void main(String[] args) {


        JFrame frm = new JFrame("Title");
        JTextField txt = new JTextField();
        JLabel lbl = new JLabel("To");
        JTextField txt2 = new JTextField();


        frm.setLayout(new GridLayout(2,2,5,5));
        frm.add(txt);
        frm.add(lbl);      
        frm.add(txt2);      

        frm.setSize(500,100);
        frm.setVisible(true);
        frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frm.setLocationRelativeTo(null);

    }
}

Someone please explaine to me how to change the location on my txt2 to be aligned w/ my txt1.
I habe been searching the net for hours but the solutions they show seems to have no effect?

what do you mean: aligned? they are aligned.
if you want them next to each other, instead of underneath, you'll need to change the values of the rows and columns in the constructor for the GridLayout.

now you set:

new GridLayout(2,2,5,5)
try with:
new GridLayout(1,3,5,5)
you have searched the net for hours, but what is it you tried so far?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.