Example usage for javax.swing JScrollPane setFocusable

List of usage examples for javax.swing JScrollPane setFocusable

Introduction

In this page you can find the example usage for javax.swing JScrollPane setFocusable.

Prototype

public void setFocusable(boolean focusable) 

Source Link

Document

Sets the focusable state of this Component to the specified value.

Usage

From source file:com.floreantpos.customer.DefaultCustomerListView.java

public void initUI() {
    setLayout(new MigLayout("fill", "[grow]", "[grow][grow][grow]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    JPanel searchPanel = new JPanel(new MigLayout());

    JLabel lblByPhone = new JLabel(Messages.getString("CustomerSelectionDialog.1")); //$NON-NLS-1$
    JLabel lblByLoyality = new JLabel(Messages.getString("CustomerSelectionDialog.16")); //$NON-NLS-1$
    JLabel lblByName = new JLabel(Messages.getString("CustomerSelectionDialog.19")); //$NON-NLS-1$

    tfMobile = new POSTextField(16);
    tfLoyaltyNo = new POSTextField(16);
    tfName = new POSTextField(16);

    tfName.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doSearchCustomer();/*from  w ww  . j  a  v a  2s .co  m*/
        }
    });
    tfLoyaltyNo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doSearchCustomer();
        }
    });
    tfMobile.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doSearchCustomer();
        }
    });

    PosButton btnSearch = new PosButton(Messages.getString("CustomerSelectionDialog.15")); //$NON-NLS-1$
    btnSearch.setFocusable(false);
    btnSearch.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doSearchCustomer();
        }
    });

    PosButton btnKeyboard = new PosButton(IconFactory.getIcon("/images/", "keyboard.png")); //$NON-NLS-1$ //$NON-NLS-2$
    btnKeyboard.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            qwertyKeyPad.setCollapsed(!qwertyKeyPad.isCollapsed());
        }
    });

    searchPanel.add(lblByPhone, "growy"); //$NON-NLS-1$
    searchPanel.add(tfMobile, "growy"); //$NON-NLS-1$
    searchPanel.add(lblByLoyality, "growy"); //$NON-NLS-1$
    searchPanel.add(tfLoyaltyNo, "growy"); //$NON-NLS-1$
    searchPanel.add(lblByName, "growy"); //$NON-NLS-1$
    searchPanel.add(tfName, "growy"); //$NON-NLS-1$
    searchPanel.add(btnKeyboard,
            "growy,w " + PosUIManager.getSize(80) + "!,h " + PosUIManager.getSize(35) + "!"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    searchPanel.add(btnSearch, ",growy,h " + PosUIManager.getSize(35) + "!"); //$NON-NLS-1$ //$NON-NLS-2$

    add(searchPanel, "cell 0 1"); //$NON-NLS-1$

    JPanel centerPanel = new JPanel(new BorderLayout());
    centerPanel.setBorder(new TitledBorder(null, POSConstants.SELECT_CUSTOMER.toUpperCase(),
            TitledBorder.LEADING, TitledBorder.TOP, null, null)); //$NON-NLS-1$

    JPanel customerListPanel = new JPanel(new BorderLayout(0, 0));
    customerListPanel.setBorder(new EmptyBorder(5, 5, 0, 5));

    customerTable = new CustomerTable();
    customerTable.setModel(new CustomerListTableModel());
    customerTable.setFocusable(false);
    customerTable.setRowHeight(60);
    customerTable.getTableHeader().setPreferredSize(new Dimension(100, 35));
    customerTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    customerTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            selectedCustomer = customerTable.getSelectedCustomer();
            if (selectedCustomer != null) {
                //btnInfo.setEnabled(true);
            } else {
                btnInfo.setEnabled(false);
            }
        }
    });
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setFocusable(false);
    scrollPane.setViewportView(customerTable);

    customerListPanel.add(scrollPane, BorderLayout.CENTER);

    JPanel panel = new JPanel(new MigLayout("hidemode 3,al center", "sg", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    btnInfo = new PosButton(Messages.getString("CustomerSelectionDialog.23")); //$NON-NLS-1$
    btnInfo.setFocusable(false);
    panel.add(btnInfo, "grow"); //$NON-NLS-1$
    btnInfo.setEnabled(false);

    PosButton btnHistory = new PosButton(Messages.getString("CustomerSelectionDialog.24")); //$NON-NLS-1$
    btnHistory.setEnabled(false);
    panel.add(btnHistory, "grow"); //$NON-NLS-1$

    btnCreateNewCustomer = new PosButton(Messages.getString("CustomerSelectionDialog.25")); //$NON-NLS-1$
    btnCreateNewCustomer.setFocusable(false);
    panel.add(btnCreateNewCustomer, "grow"); //$NON-NLS-1$
    btnCreateNewCustomer.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doCreateNewCustomer();
        }
    });

    btnRemoveCustomer = new PosButton(Messages.getString("CustomerSelectionDialog.26")); //$NON-NLS-1$
    btnRemoveCustomer.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doRemoveCustomerFromTicket();
        }
    });
    panel.add(btnRemoveCustomer, "grow"); //$NON-NLS-1$

    PosButton btnSelect = new PosButton(Messages.getString("CustomerSelectionDialog.28")); //$NON-NLS-1$
    btnSelect.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (isCreateNewTicket()) {
                doCreateNewTicket();
            } else {
                closeDialog(false);
            }
        }
    });
    panel.add(btnSelect, "grow"); //$NON-NLS-1$

    btnCancel = new PosButton(Messages.getString("CustomerSelectionDialog.29")); //$NON-NLS-1$
    btnCancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            closeDialog(true);
        }
    });
    panel.add(btnCancel, "grow"); //$NON-NLS-1$

    customerListPanel.add(panel, BorderLayout.SOUTH);
    centerPanel.add(customerListPanel, BorderLayout.CENTER); //$NON-NLS-1$

    add(centerPanel, "cell 0 2,grow"); //$NON-NLS-1$

    qwertyKeyPad = new com.floreantpos.swing.QwertyKeyPad();
    qwertyKeyPad.setCollapsed(false);
    add(qwertyKeyPad, "cell 0 3,grow"); //$NON-NLS-1$
}