All pastes #920016 Raw Edit

mrcheeks

public text v1 · immutable
#920016 ·published 2008-02-27 04:06 UTC
rendered paste body
 class IndentityPanelComponent extends JComponent {
        private String[] titles = {
                "Real name", "First nick", "Second nick", "Third nick"
            };
        private JLabel[] labels = new JLabel[4];
        private JTextField[] txt = new JTextField[4];

        public IndentityPanelComponent() {
            setLayout(new GridBagLayout());

            GridBagConstraints gbc = new GridBagConstraints();

            for (int i = 0; i < titles.length; i++) {
                labels[i] = new JLabel(titles[i]);
                txt[i] = new JTextField();
                gbc = new GridBagConstraints();
                gbc.insets = new Insets(2, 2, 2, 2);
                gbc.anchor = GridBagConstraints.NORTHWEST;
                gbc.gridy = i;
                gbc.gridx = 0;

                add(labels[i], gbc);

                gbc.gridx = 1;
                gbc.gridwidth = 2;
                gbc.weightx = .7;
                gbc.fill = GridBagConstraints.HORIZONTAL;

                add(txt[i], gbc);
            }
        }
    }