Here's my code:


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

public class GUI_example extends JFrame {

private final static long serialVersionUID = 1L;

JFrame frame;

JLabel labelIndex;
JLabel labelCategory;
JLabel labelUnicode;

JTextField textFieldIndex;
JTextField textFieldCategory;
JTextField textFieldUnicode;

public GUI_example() {
super();
createGUI();
}

public void createGUI() {

frame = new JFrame();
frame.setPreferredSize(new Dimension(600,600));
frame.setTitle("Hello!");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);

Container pane = frame.getContentPane();
pane.setLayout(new GridBagLayout());

GridBagConstraints c1 = new GridBagConstraints();

labelIndex = new JLabel("Index: ");
c1.anchor = GridBagConstraints.NORTHWEST;
c1.weightx = 0.5;
c1.weighty = 0.5;
c1.ipady = 10;
c1.gridx = 0;
c1.gridy = 0;
pane.add(labelIndex,c1);

textFieldIndex = new JTextField("Some index...");
c1.gridx = 1;
c1.gridy = 0;
pane.add(textFieldIndex,c1);

labelCategory = new JLabel("Category: ");
c1.anchor = GridBagConstraints.NORTHWEST;
c1.weightx = 0.5;
c1.weighty = 0.5;
c1.gridx = 0;
c1.gridy = 1;
pane.add(labelCategory,c1);

textFieldCategory = new JTextField("Some category...");
c1.gridx = 1;
c1.gridy = 1;
pane.add(textFieldCategory,c1);

frame.pack();
frame.setVisible(true);
}

public static void main(String[] args) {
new GUI_example();
}

}