Search in sources :

Example 1 with CustomFocusTraversalPolicy

use of course_generator.utils.CustomFocusTraversalPolicy in project Course_Generator by patrovite.

the class frmSearchPoint method initComponents.

/**
 * This method is called to initialize the form.
 */
private void initComponents() {
    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle(bundle.getString("frmSearchPoint.title"));
    setAlwaysOnTop(true);
    setType(java.awt.Window.Type.NORMAL);
    setResizable(false);
    // -- Layout
    // ------------------------------------------------------------
    Container paneGlobal = getContentPane();
    paneGlobal.setLayout(new GridBagLayout());
    // -- Search area
    pnSearch = new javax.swing.JPanel();
    pnSearch.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("frmSearchPoint.pnSearch.border.title")));
    pnSearch.setLayout(new GridBagLayout());
    // -- Latitude
    lbLatitude = new javax.swing.JLabel();
    lbLatitude.setFocusable(false);
    lbLatitude.setText(bundle.getString("frmSearchPoint.lbLatitude.text"));
    Utils.addComponent(pnSearch, lbLatitude, 0, 0, 1, 1, 0, 0, 0, 5, 2, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    tfLatitude = new JTextFieldLimit(10);
    tfLatitude.setFocusable(true);
    // tfLatitude.setDocument(new JTextFieldLimit(10));
    tfLatitude.setMinimumSize(new Dimension(100, 20));
    tfLatitude.setHorizontalAlignment(javax.swing.JTextField.CENTER);
    Utils.addComponent(pnSearch, tfLatitude, 1, 0, 1, 1, 1, 0, 0, 5, 2, 5, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // -- Longitude
    lbLongitude = new javax.swing.JLabel();
    lbLongitude.setFocusable(false);
    lbLongitude.setText(bundle.getString("frmSearchPoint.lbLongitude.text"));
    Utils.addComponent(pnSearch, lbLongitude, 0, 1, 1, 1, 0, 0, 0, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    tfLongitude = new JTextFieldLimit(10);
    tfLongitude.setFocusable(true);
    // tfLongitude.setDocument(new JTextFieldLimit(10));
    tfLongitude.setHorizontalAlignment(javax.swing.JTextField.CENTER);
    Utils.addComponent(pnSearch, tfLongitude, 1, 1, 1, 1, 1, 0, 0, 5, 0, 5, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    btSearch = new javax.swing.JButton();
    btSearch.setFocusable(true);
    btSearch.setToolTipText(bundle.getString("frmSearchPoint.btSearch.tooltips"));
    btSearch.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/search.png")));
    btSearch.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            SearchPoint();
        }
    });
    Utils.addComponent(pnSearch, btSearch, 2, 0, 1, 2, 0, 0, 0, 5, 0, 5, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);
    Utils.addComponent(paneGlobal, pnSearch, 0, 0, 1, 1, 0, 0, 0, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // -- Result area
    pnResult = new javax.swing.JPanel();
    pnResult.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("frmSearchPoint.pnResult.border.title")));
    pnResult.setLayout(new GridBagLayout());
    // -- Found point
    lbPointFound = new javax.swing.JLabel();
    lbPointFound.setFocusable(false);
    lbPointFound.setText(bundle.getString("frmSearchPoint.lbPointFound.text"));
    Utils.addComponent(pnResult, lbPointFound, 0, 0, 1, 1, 0, 0, 0, 5, 2, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    lbPointFoundVal = new javax.swing.JLabel();
    lbPointFoundVal.setFocusable(false);
    lbPointFoundVal.setHorizontalAlignment(javax.swing.JTextField.CENTER);
    lbPointFoundVal.setMinimumSize(new Dimension(100, 20));
    lbPointFoundVal.setPreferredSize(new Dimension(100, 20));
    lbPointFoundVal.setBackground(new java.awt.Color(255, 255, 255));
    lbPointFoundVal.setOpaque(true);
    lbPointFoundVal.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
    Utils.addComponent(pnResult, lbPointFoundVal, 1, 0, 1, 1, 1, 0, 0, 5, 2, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // -- Distance from point
    lbDistanceFromPoint = new javax.swing.JLabel();
    lbDistanceFromPoint.setFocusable(false);
    lbDistanceFromPoint.setText(bundle.getString("frmSearchPoint.lbDistanceFromPoint.text"));
    Utils.addComponent(pnResult, lbDistanceFromPoint, 0, 1, 1, 1, 0, 0, 0, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    lbDistanceFromPointVal = new javax.swing.JLabel();
    lbDistanceFromPointVal.setFocusable(false);
    lbDistanceFromPointVal.setHorizontalAlignment(javax.swing.JTextField.CENTER);
    lbDistanceFromPointVal.setMinimumSize(new Dimension(100, 20));
    lbDistanceFromPointVal.setPreferredSize(new Dimension(100, 20));
    lbDistanceFromPointVal.setBackground(new java.awt.Color(255, 255, 255));
    lbDistanceFromPointVal.setOpaque(true);
    lbDistanceFromPointVal.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
    Utils.addComponent(pnResult, lbDistanceFromPointVal, 1, 1, 1, 1, 1, 0, 0, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    Utils.addComponent(paneGlobal, pnResult, 0, 1, 1, 1, 0, 1, 0, 5, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // == Close button
    // ===========================================================
    btClose = new javax.swing.JButton();
    btClose.setFocusable(true);
    btClose.setText(bundle.getString("frmSearchPoint.btClose.text"));
    btClose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/cancel.png")));
    btClose.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            setVisible(false);
        }
    });
    Utils.addComponent(paneGlobal, btClose, 0, 2, GridBagConstraints.REMAINDER, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL);
    // -- Configure the travel policy (TAB mvt)
    Vector<Component> order = new Vector<Component>(4);
    order.add(tfLatitude);
    order.add(tfLongitude);
    order.add(btSearch);
    order.add(btClose);
    newPolicy = new CustomFocusTraversalPolicy(order);
    // -- Set the travel policy
    setFocusTraversalPolicy(newPolicy);
    // --
    pack();
    // -- Center the windows
    setLocationRelativeTo(null);
}
Also used : Color(java.awt.Color) JButton(javax.swing.JButton) GridBagLayout(java.awt.GridBagLayout) CustomFocusTraversalPolicy(course_generator.utils.CustomFocusTraversalPolicy) Dimension(java.awt.Dimension) ActionEvent(java.awt.event.ActionEvent) Container(java.awt.Container) JLabel(javax.swing.JLabel) JTextFieldLimit(course_generator.utils.JTextFieldLimit) JComponent(javax.swing.JComponent) Component(java.awt.Component) Vector(java.util.Vector) JPanel(javax.swing.JPanel)

Aggregations

CustomFocusTraversalPolicy (course_generator.utils.CustomFocusTraversalPolicy)1 JTextFieldLimit (course_generator.utils.JTextFieldLimit)1 Color (java.awt.Color)1 Component (java.awt.Component)1 Container (java.awt.Container)1 Dimension (java.awt.Dimension)1 GridBagLayout (java.awt.GridBagLayout)1 ActionEvent (java.awt.event.ActionEvent)1 Vector (java.util.Vector)1 JButton (javax.swing.JButton)1 JComponent (javax.swing.JComponent)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1