Example usage for java.awt GridBagConstraints FIRST_LINE_END

List of usage examples for java.awt GridBagConstraints FIRST_LINE_END

Introduction

In this page you can find the example usage for java.awt GridBagConstraints FIRST_LINE_END.

Prototype

int FIRST_LINE_END

To view the source code for java.awt GridBagConstraints FIRST_LINE_END.

Click Source Link

Document

Place the component in the corner of its display area where the first line of text on a page would normally end for the current ComponentOrientation .

Usage

From source file:Main.java

public MyPanel() {
    JTextField labelA = new JTextField("Your A component");
    JTextField labelB = new JTextField("Your B component");
    JTextField labelC = new JTextField("Your C component");
    JTextField labelD = new JTextField("Top Right D");

    JPanel north = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.FIRST_LINE_END;
    gbc.weightx = 1;//from ww w.  j  av  a2 s  .  c o  m
    gbc.insets = new Insets(10, 10, 10, 10);
    north.add(labelD, gbc);

    JPanel south = new JPanel(new GridBagLayout());
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.gridy = 0;
    south.add(labelA, gbc);
    gbc.gridy = 1;
    south.add(labelB, gbc);
    gbc.gridy = 2;
    south.add(labelC, gbc);

    setLayout(new BorderLayout());
    add(north, BorderLayout.NORTH);
    add(south, BorderLayout.CENTER);
}

From source file:eu.ggnet.dwoss.receipt.unit.UnitView.java

/**
 * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form/*from   w  ww.java 2 s . c om*/
 * Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;

    manufacturerButtonGroup = new javax.swing.ButtonGroup();
    jPanel1 = new javax.swing.JPanel();
    unitSplitPane = new javax.swing.JSplitPane();
    unitWritePanel = new javax.swing.JPanel();
    internalCommentAreaScrollPane = new javax.swing.JScrollPane();
    internalCommentArea = new javax.swing.JTextArea();
    commentAreaScrollPane = new javax.swing.JScrollPane();
    commentArea = new javax.swing.JTextArea();
    unitItemLabel = new javax.swing.JLabel();
    unitStatusLabel = new javax.swing.JLabel();
    unitStateBox = new javax.swing.JComboBox();
    editProductButton = new javax.swing.JButton();
    partNoField = new javax.swing.JTextField();
    refurbishedIdField = new javax.swing.JTextField();
    unitSnLabel = new javax.swing.JLabel();
    unitNumberLabel = new javax.swing.JLabel();
    serialField = new javax.swing.JTextField();
    editRefurbishedIdButton = new javax.swing.JButton();
    mfgLabel = new javax.swing.JLabel();
    mfgDateChooser = new com.toedter.calendar.JDateChooser();
    jLabel3 = new javax.swing.JLabel();
    warrantyTillChooser = new com.toedter.calendar.JDateChooser();
    jLabel4 = new javax.swing.JLabel();
    warrantyTypeChooser = new javax.swing.JComboBox();
    manufacturerPanel = new javax.swing.JPanel();
    contractorBox = new javax.swing.JComboBox();
    jScrollPane3 = new javax.swing.JScrollPane();
    equipmentTable = new javax.swing.JTable();
    jScrollPane4 = new javax.swing.JScrollPane();
    commentTable = new javax.swing.JTable();
    jScrollPane5 = new javax.swing.JScrollPane();
    internalCommentTable = new javax.swing.JTable();
    unitReadPanel = new javax.swing.JPanel();
    unitShipLabel = new javax.swing.JLabel();
    unitShipField = new javax.swing.JTextField();
    unitOwnerLabel = new javax.swing.JLabel();
    unitOwnerField = new javax.swing.JTextField();
    jLabel1 = new javax.swing.JLabel();
    jScrollPane2 = new javax.swing.JScrollPane();
    detailArea = new javax.swing.JEditorPane();
    messagesButton = new javax.swing.JButton();
    operationButtonPanel = new javax.swing.JPanel();
    cancelButton = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle("Gert bearbeiten/aufnehmen");
    setMinimumSize(new java.awt.Dimension(1080, 700));
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosing(java.awt.event.WindowEvent evt) {
            formWindowClosing(evt);
        }
    });

    unitSplitPane.setDividerLocation(600);
    unitSplitPane.setResizeWeight(1.0);
    unitSplitPane.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    unitSplitPane.setDoubleBuffered(true);

    unitWritePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
            javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED,
                    new java.awt.Color(204, 204, 255), new java.awt.Color(51, 51, 51))));
    unitWritePanel.setMinimumSize(new java.awt.Dimension(500, 400));
    unitWritePanel.setPreferredSize(new java.awt.Dimension(500, 400));
    unitWritePanel.setLayout(new java.awt.GridBagLayout());

    internalCommentArea.setColumns(20);
    internalCommentArea.setLineWrap(true);
    internalCommentArea.setRows(5);
    internalCommentArea.setWrapStyleWord(true);
    internalCommentAreaScrollPane.setViewportView(internalCommentArea);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 10;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START;
    gridBagConstraints.weighty = 0.1;
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    unitWritePanel.add(internalCommentAreaScrollPane, gridBagConstraints);

    commentArea.setColumns(20);
    commentArea.setLineWrap(true);
    commentArea.setRows(5);
    commentArea.setWrapStyleWord(true);
    commentAreaScrollPane.setViewportView(commentArea);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 10;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START;
    gridBagConstraints.weighty = 0.1;
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    unitWritePanel.add(commentAreaScrollPane, gridBagConstraints);

    unitItemLabel.setText("ArtikelNr:");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    unitWritePanel.add(unitItemLabel, gridBagConstraints);

    unitStatusLabel.setText("Zustand:");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    unitWritePanel.add(unitStatusLabel, gridBagConstraints);

    unitStateBox.setNextFocusableComponent(warrantyTillChooser);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    unitWritePanel.add(unitStateBox, gridBagConstraints);

    editProductButton.setText("Edit");
    editProductButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            editProductButtonActionPerformed(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    unitWritePanel.add(editProductButton, gridBagConstraints);

    partNoField.setName("partNo"); // NOI18N
    partNoField.setNextFocusableComponent(unitStateBox);
    partNoField.addFocusListener(new java.awt.event.FocusAdapter() {
        public void focusLost(java.awt.event.FocusEvent evt) {
            partNoFieldFocusLost(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    unitWritePanel.add(partNoField, gridBagConstraints);

    refurbishedIdField.setName("refurbishId"); // NOI18N
    refurbishedIdField.setNextFocusableComponent(serialField);
    refurbishedIdField.addFocusListener(new java.awt.event.FocusAdapter() {
        public void focusLost(java.awt.event.FocusEvent evt) {
            refurbishedIdFieldFocusLost(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 0.1;
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    unitWritePanel.add(refurbishedIdField, gridBagConstraints);

    unitSnLabel.setText("SerienNr:");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
    gridBagConstraints.insets = new java.awt.Insets(5, 2, 2, 2);
    unitWritePanel.add(unitSnLabel, gridBagConstraints);

    unitNumberLabel.setText("SopoNr:");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    unitWritePanel.add(unitNumberLabel, gridBagConstraints);

    serialField.setName("serial"); // NOI18N
    serialField.setNextFocusableComponent(partNoField);
    serialField.addFocusListener(new java.awt.event.FocusAdapter() {
        public void focusLost(java.awt.event.FocusEvent evt) {
            serialFieldFocusLost(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    unitWritePanel.add(serialField, gridBagConstraints);

    editRefurbishedIdButton.setText("Edit");
    editRefurbishedIdButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            editRefurbishedIdButtonActionPerformed(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    unitWritePanel.add(editRefurbishedIdButton, gridBagConstraints);

    mfgLabel.setText("MFG Date:");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
    unitWritePanel.add(mfgLabel, gridBagConstraints);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    unitWritePanel.add(mfgDateChooser, gridBagConstraints);

    jLabel3.setText("Garantie bis:");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 7;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_END;
    gridBagConstraints.insets = new java.awt.Insets(8, 0, 0, 0);
    unitWritePanel.add(jLabel3, gridBagConstraints);

    warrantyTillChooser.setEnabled(false);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 7;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.PAGE_START;
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    unitWritePanel.add(warrantyTillChooser, gridBagConstraints);

    jLabel4.setText("Garantietyp:");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
    unitWritePanel.add(jLabel4, gridBagConstraints);

    warrantyTypeChooser.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            warrantyTypeChooserActionPerformed(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 6;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START;
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    unitWritePanel.add(warrantyTypeChooser, gridBagConstraints);

    manufacturerPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Hersteller Support"));

    contractorBox.setModel(
            new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
    contractorBox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            contractorBoxActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout manufacturerPanelLayout = new javax.swing.GroupLayout(manufacturerPanel);
    manufacturerPanel.setLayout(manufacturerPanelLayout);
    manufacturerPanelLayout.setHorizontalGroup(
            manufacturerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
                    contractorBox, javax.swing.GroupLayout.Alignment.TRAILING, 0, 333, Short.MAX_VALUE));
    manufacturerPanelLayout.setVerticalGroup(
            manufacturerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(contractorBox, javax.swing.GroupLayout.Alignment.TRAILING));

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    unitWritePanel.add(manufacturerPanel, gridBagConstraints);

    equipmentTable
            .setModel(new javax.swing.table.DefaultTableModel(
                    new Object[][] { { null, null, null, null }, { null, null, null, null },
                            { null, null, null, null }, { null, null, null, null } },
                    new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
    jScrollPane3.setViewportView(equipmentTable);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridheight = 9;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 0.1;
    gridBagConstraints.weighty = 0.2;
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    unitWritePanel.add(jScrollPane3, gridBagConstraints);

    commentTable
            .setModel(new javax.swing.table.DefaultTableModel(
                    new Object[][] { { null, null, null, null }, { null, null, null, null },
                            { null, null, null, null }, { null, null, null, null } },
                    new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
    jScrollPane4.setViewportView(commentTable);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 8;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weighty = 0.2;
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    unitWritePanel.add(jScrollPane4, gridBagConstraints);

    internalCommentTable
            .setModel(new javax.swing.table.DefaultTableModel(
                    new Object[][] { { null, null, null, null }, { null, null, null, null },
                            { null, null, null, null }, { null, null, null, null } },
                    new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
    jScrollPane5.setViewportView(internalCommentTable);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 9;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 0.1;
    gridBagConstraints.weighty = 0.2;
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    unitWritePanel.add(jScrollPane5, gridBagConstraints);

    unitSplitPane.setLeftComponent(unitWritePanel);

    unitReadPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
            javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED,
                    new java.awt.Color(204, 204, 255), java.awt.Color.black)));

    unitShipLabel.setText("Shipment ID:");

    unitShipField.setEditable(false);
    unitShipField.setFocusable(false);

    unitOwnerLabel.setText("Besitzer:");

    unitOwnerField.setEditable(false);
    unitOwnerField.setFocusable(false);

    jLabel1.setText("Details:");

    jScrollPane2.setFocusable(false);

    detailArea.setContentType("text/html"); // NOI18N
    detailArea.setFocusable(false);
    jScrollPane2.setViewportView(detailArea);

    messagesButton.setText("Meldungen");
    messagesButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            messagesButtonActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout unitReadPanelLayout = new javax.swing.GroupLayout(unitReadPanel);
    unitReadPanel.setLayout(unitReadPanelLayout);
    unitReadPanelLayout.setHorizontalGroup(unitReadPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 393, Short.MAX_VALUE)
            .addGroup(unitReadPanelLayout.createSequentialGroup()
                    .addGroup(unitReadPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(unitShipLabel).addComponent(unitOwnerLabel))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(unitReadPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(unitShipField, javax.swing.GroupLayout.DEFAULT_SIZE, 308,
                                    Short.MAX_VALUE)
                            .addComponent(unitOwnerField, javax.swing.GroupLayout.DEFAULT_SIZE, 308,
                                    Short.MAX_VALUE)))
            .addGroup(unitReadPanelLayout.createSequentialGroup().addComponent(jLabel1).addGap(0, 346,
                    Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, unitReadPanelLayout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE).addComponent(messagesButton)));
    unitReadPanelLayout.setVerticalGroup(unitReadPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(unitReadPanelLayout.createSequentialGroup().addGroup(unitReadPanelLayout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(unitShipLabel)
                    .addComponent(unitShipField, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                            unitReadPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(unitOwnerLabel).addComponent(unitOwnerField,
                                            javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel1)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 414, Short.MAX_VALUE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(messagesButton)));

    unitSplitPane.setRightComponent(unitReadPanel);

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(jPanel1Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap()
                    .addComponent(unitSplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 1008, Short.MAX_VALUE)
                    .addContainerGap()));
    jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout
                    .createSequentialGroup().addContainerGap().addComponent(unitSplitPane).addContainerGap()));

    operationButtonPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    operationButtonPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));

    cancelButton.setText("Abbrechen");
    cancelButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            cancelButtonActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                    Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                    layout.createSequentialGroup().addContainerGap().addComponent(cancelButton)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(operationButtonPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(operationButtonPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 45,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                    layout.createSequentialGroup()
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(cancelButton).addContainerGap()))));

    pack();
}

From source file:typoscript.TypoScriptPluginOptions.java

/**
 * This method is STATIC and will give you a GridBagConstraints with the required attributes
 * @param gridx Horizontal grid position of the element
 * @param gridy Vertical grid position of the element
 * @param gridwidth How many cells the element should span
 * @param gridheight How many rows the element should span
 * @param position either left, centre, right, top-left, top-right, bottom-left, bottom-right
 * @return a GridBagConstraints object with the desired attributes.
 *///from w ww  . j  a  v a2s  .co m
public static GridBagConstraints getConstraint(int gridx, int gridy, int gridwidth, int gridheight,
        String position) {
    GridBagConstraints tempGbc = new GridBagConstraints();
    tempGbc.gridx = gridx;
    tempGbc.gridy = gridy;
    tempGbc.gridwidth = gridwidth;
    tempGbc.gridheight = gridheight;

    if (position.equals("left")) {
        tempGbc.anchor = GridBagConstraints.LINE_START;
    } else if (position.equals("centre")) {
        tempGbc.anchor = GridBagConstraints.CENTER;
    } else if (position.equals("right")) {
        tempGbc.anchor = GridBagConstraints.LINE_END;
    } else if (position.equals("top-left")) {
        tempGbc.anchor = GridBagConstraints.FIRST_LINE_START;
    } else if (position.equals("top-right")) {
        tempGbc.anchor = GridBagConstraints.FIRST_LINE_END;
    } else if (position.equals("bottom-left")) {
        tempGbc.anchor = GridBagConstraints.LAST_LINE_START;
    } else if (position.equals("bottom-right")) {
        tempGbc.anchor = GridBagConstraints.LAST_LINE_END;
    } else {
        // error
        System.out.println(
                "getConstraint was provided with an invalid position '" + position + "', returning null");
        return null;
    }

    return tempGbc;
}