Example usage for javax.swing JList requestFocusInWindow

List of usage examples for javax.swing JList requestFocusInWindow

Introduction

In this page you can find the example usage for javax.swing JList requestFocusInWindow.

Prototype

public boolean requestFocusInWindow() 

Source Link

Document

Requests that this Component gets the input focus.

Usage

From source file:com.kstenschke.copypastestack.ToolWindow.java

private void initItemsPreview() {
    this.form.labelPreviewImage.setText("");
    this.form.panelPreviewImage.setVisible(false);
    this.form.scrollPanePreview.setVisible(true);

    // Install listener to update shown preview from current clipboard
    final FocusListenerViewClipboard focusListenerViewClipboard = new FocusListenerViewClipboard(this);
    this.form.listPreview.addFocusListener(focusListenerViewClipboard);
    this.form.checkBoxScale50Percent
            .addChangeListener(new ChangeListenerResizePreview(focusListenerViewClipboard));

    this.form.buttonRefreshPreview.addMouseListener(new MouseListenerBase(StaticTexts.INFO_REFRESH_PREVIEW));
    final JList listPreview = this.form.listPreview;
    this.form.buttonRefreshPreview.addActionListener(new ActionListener() {
        @Override//from  w  w  w. ja  v a2  s .  co  m
        public void actionPerformed(ActionEvent e) {
            focusListenerViewClipboard.updateClipboardPreview();
            listPreview.requestFocusInWindow();
            listPreview.setSelectedIndex(0);
        }
    });

    // Install items listener to update shown preview from stacked items
    this.form.listClipItems.addListSelectionListener(new ListSelectionListenerItemsList(this));

    // Add popup listener
    this.form.textPanePreview.addMouseListener(new PopupPreview(this).getPopupListener());
}