Example usage for java.awt GridBagConstraints LAST_LINE_END

List of usage examples for java.awt GridBagConstraints LAST_LINE_END

Introduction

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

Prototype

int LAST_LINE_END

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

Click Source Link

Document

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

Usage

From source file:be.ac.ua.comp.scarletnebula.gui.windows.GUI.java

private JPanel getOverlayPanel() {
    final JPanel overlayPanel = new JPanel();
    overlayPanel.setOpaque(false);// w w w  .ja  v a  2  s  .  co  m
    overlayPanel.setLayout(new GridBagLayout());
    filterTextField.addKeyListener(new KeyListener() {
        @Override
        public void keyTyped(final KeyEvent e) {

        }

        @Override
        public void keyReleased(final KeyEvent e) {
        }

        @Override
        public void keyPressed(final KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                hideFilter();
            }
        }
    });
    filterTextField.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void removeUpdate(final DocumentEvent e) {
            textChanged();

        }

        @Override
        public void insertUpdate(final DocumentEvent e) {
            textChanged();
        }

        @Override
        public void changedUpdate(final DocumentEvent e) {

        }

        private void textChanged() {
            serverListModel.filter(filterTextField.getText());
        }
    });

    final SearchField searchField = new SearchField(filterTextField);

    final ImageIcon closeIcon = Utils.icon("cross16.png");
    final JButton closeButton = new JButton(closeIcon);
    closeButton.setBounds(10, 10, closeIcon.getIconWidth(), closeIcon.getIconHeight());
    closeButton.setMargin(new Insets(0, 0, 0, 0));
    closeButton.setOpaque(false);
    closeButton.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    closeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            hideFilter();
        }
    });

    searchPanel.add(searchField);
    searchPanel.add(closeButton);
    // searchPanel.setBorder(BorderFactory
    // .createBevelBorder(BevelBorder.RAISED));
    searchPanel.setBorder(BorderFactory.createEtchedBorder());
    searchPanel.setVisible(false);
    searchPanel.setAlignmentX(RIGHT_ALIGNMENT);

    final GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.LAST_LINE_END;
    c.fill = GridBagConstraints.NONE;
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.insets = new Insets(3, 3, 3, 3);
    overlayPanel.add(searchPanel, c);
    return overlayPanel;
}

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  w  w .ja v a2 s  . 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;
}