Search in sources :

Example 21 with KeyAdapter

use of java.awt.event.KeyAdapter in project intellij-community by JetBrains.

the class ToBeMergedDialog method addRevisionListListeners.

private void addRevisionListListeners() {
    final int checkboxWidth = new JCheckBox().getPreferredSize().width;
    new ClickListener() {

        @Override
        public boolean onClick(@NotNull MouseEvent e, int clickCount) {
            final int idx = myRevisionsList.rowAtPoint(e.getPoint());
            if (idx >= 0) {
                final Rectangle baseRect = myRevisionsList.getCellRect(idx, 0, false);
                baseRect.setSize(checkboxWidth, baseRect.height);
                if (baseRect.contains(e.getPoint())) {
                    toggleInclusion(myRevisionsModel.getRowValue(idx));
                    myRevisionsList.repaint(baseRect);
                }
            }
            return true;
        }
    }.installOn(myRevisionsList);
    myRevisionsList.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            if (KeyEvent.VK_SPACE == e.getKeyCode()) {
                List<SvnChangeList> selected = myRevisionsList.getSelectedObjects();
                if (!selected.isEmpty()) {
                    selected.forEach(ToBeMergedDialog.this::toggleInclusion);
                    myRevisionsList.repaint();
                    e.consume();
                }
            }
        }
    });
}
Also used : KeyEvent(java.awt.event.KeyEvent) MouseEvent(java.awt.event.MouseEvent) KeyAdapter(java.awt.event.KeyAdapter) Collections.singletonList(java.util.Collections.singletonList) SvnChangeList(org.jetbrains.idea.svn.history.SvnChangeList) List(java.util.List) ContainerUtilRt.emptyList(com.intellij.util.containers.ContainerUtilRt.emptyList)

Example 22 with KeyAdapter

use of java.awt.event.KeyAdapter in project Botnak by Gocnak.

the class GUIStreams method initComponents.

private void initComponents() {
    JScrollPane scrollPane1 = new JScrollPane();
    followedList = new JList<>();
    listLabel = new JLabel();
    JLabel label3 = new JLabel();
    newChannel = new JTextField();
    JSeparator separator1 = new JSeparator();
    JSeparator separator2 = new JSeparator();
    JButton addStreamButton = new JButton();
    JButton doneButton = new JButton();
    //======== this ========
    setTitle("Add a Stream");
    setIconImage(new ImageIcon(getClass().getResource("/image/icon.png")).getImage());
    setResizable(false);
    Container contentPane = getContentPane();
    //======== scrollPane1 ========
    {
        //---- followedList ----
        setFollowedListModel("Enable \"Read followed Streams\" on", " your Oauth key!");
        followedList.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseReleased(MouseEvent e) {
                String selected = followedList.getSelectedValue();
                if (selected != null) {
                    newChannel.setText(selected);
                    newChannel.requestFocusInWindow();
                }
            }
        });
        followedList.setFocusable(false);
        scrollPane1.setViewportView(followedList);
    }
    //---- listLabel ----
    listLabel.setText("Followed Streams:");
    //---- label3 ----
    label3.setText("Twitch Username:");
    //---- newChannel ----
    newChannel.setFont(new Font("Tahoma", Font.PLAIN, 12));
    newChannel.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            newChannelKeyReleased(e);
        }
    });
    //---- addStreamButton ----
    addStreamButton.setText("Add");
    addStreamButton.setFocusable(false);
    addStreamButton.addActionListener(e -> addStreamButtonActionPerformed());
    //---- doneButton ----
    doneButton.setText("Close");
    doneButton.setFocusable(false);
    doneButton.addActionListener(e -> doneButtonActionPerformed());
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    GroupLayout contentPaneLayout = new GroupLayout(contentPane);
    contentPane.setLayout(contentPaneLayout);
    contentPaneLayout.setHorizontalGroup(contentPaneLayout.createParallelGroup().addGroup(contentPaneLayout.createSequentialGroup().addContainerGap().addGroup(contentPaneLayout.createParallelGroup().addGroup(contentPaneLayout.createSequentialGroup().addComponent(addStreamButton, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 28, Short.MAX_VALUE).addComponent(doneButton, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)).addGroup(contentPaneLayout.createSequentialGroup().addGroup(contentPaneLayout.createParallelGroup().addComponent(listLabel).addComponent(scrollPane1, GroupLayout.PREFERRED_SIZE, 150, GroupLayout.PREFERRED_SIZE).addComponent(label3).addComponent(newChannel, GroupLayout.PREFERRED_SIZE, 150, GroupLayout.PREFERRED_SIZE)).addGap(0, 0, Short.MAX_VALUE))).addContainerGap()).addComponent(separator1, GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE).addComponent(separator2, GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE));
    contentPaneLayout.setVerticalGroup(contentPaneLayout.createParallelGroup().addGroup(contentPaneLayout.createSequentialGroup().addContainerGap().addComponent(listLabel).addGap(6, 6, 6).addComponent(scrollPane1, GroupLayout.PREFERRED_SIZE, 125, GroupLayout.PREFERRED_SIZE).addGap(8, 8, 8).addComponent(separator1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(label3).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(newChannel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(separator2, GroupLayout.PREFERRED_SIZE, 2, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(addStreamButton, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE).addComponent(doneButton, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE)).addContainerGap(3, Short.MAX_VALUE)));
    pack();
    setLocationRelativeTo(getOwner());
}
Also used : MouseEvent(java.awt.event.MouseEvent) KeyAdapter(java.awt.event.KeyAdapter) MouseAdapter(java.awt.event.MouseAdapter) KeyEvent(java.awt.event.KeyEvent)

Example 23 with KeyAdapter

use of java.awt.event.KeyAdapter in project adempiere by adempiere.

the class JasperViewer method initComponents.

/** 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 Editor.
     */
private //GEN-BEGIN:initComponents
void initComponents() {
    pnlMain = new javax.swing.JPanel();
    setTitle(m_title);
    addWindowListener(new java.awt.event.WindowAdapter() {

        public void windowClosing(java.awt.event.WindowEvent evt) {
            exitForm();
        }
    });
    addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent event) {
            if (event.getKeyCode() == KeyEvent.VK_ESCAPE)
                exitForm();
        }

        public void keyTyped(KeyEvent event) {
            super.keyTyped(event);
        }
    });
    pnlMain.setLayout(new java.awt.BorderLayout());
    getContentPane().add(pnlMain, java.awt.BorderLayout.CENTER);
    pack();
    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setSize(new java.awt.Dimension(750, 550));
    setLocation((screenSize.width - 750) / 2, (screenSize.height - 550) / 2);
}
Also used : KeyEvent(java.awt.event.KeyEvent) KeyAdapter(java.awt.event.KeyAdapter) BorderLayout(java.awt.BorderLayout)

Example 24 with KeyAdapter

use of java.awt.event.KeyAdapter in project aerospike-client-java by aerospike.

the class GuiDisplay method initialize.

/**
	 * Initialize the contents of the frame.
	 */
private void initialize() {
    frmAerospikeExamples = new JFrame();
    frmAerospikeExamples.setTitle("Aerospike Java Client Examples");
    frmAerospikeExamples.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frmAerospikeExamples.pack();
    frmAerospikeExamples.getContentPane().setLayout(new BorderLayout(0, 0));
    splitPane = new JSplitPane();
    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    frmAerospikeExamples.getContentPane().add(splitPane, BorderLayout.CENTER);
    mainPanel = new JPanel();
    splitPane.setLeftComponent(mainPanel);
    mainPanel.setLayout(new BorderLayout(0, 0));
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    runButton = new JButton("Run");
    runButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent ev) {
            consoleTextArea.setText("");
            run_selected_examples();
        }
    });
    buttonPanel.add(runButton);
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    exitButton = new JButton("Quit");
    exitButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent arg0) {
            Container Frame = exitButton.getParent();
            do {
                Frame = Frame.getParent();
            } while (!(Frame instanceof JFrame));
            ((JFrame) Frame).dispose();
        }
    });
    buttonPanel.add(exitButton);
    sourceTextPane = new JTextArea();
    sourceTextPane.setTabSize(2);
    sourceTextPane.setEditable(false);
    scrollPane = new JScrollPane(sourceTextPane);
    scrollPane.setViewportBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    scrollPane.setPreferredSize(new Dimension(600, 100));
    mainPanel.add(scrollPane, BorderLayout.CENTER);
    connectionPanel = new JPanel();
    connectionPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    lblServerHost = new JLabel("Server Host");
    connectionPanel.add(lblServerHost);
    seedHostTextField = new JTextField();
    seedHostTextField.addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            params.host = seedHostTextField.getText();
        }
    });
    connectionPanel.add(seedHostTextField);
    seedHostTextField.setColumns(10);
    lblPort = new JLabel("Port");
    connectionPanel.add(lblPort);
    portTextField = new JTextField();
    portTextField.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent arg0) {
            String newValue = namespaceTextField.getText();
            if (newValue != null && newValue != "") {
                try {
                    params.port = Integer.parseInt(newValue);
                } catch (NumberFormatException ne) {
                //ne.printStackTrace();
                }
            }
        }
    });
    connectionPanel.add(portTextField);
    portTextField.setColumns(4);
    lblusername = new JLabel("User");
    connectionPanel.add(lblusername);
    usernameTextField = new JTextField();
    usernameTextField.addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            params.user = usernameTextField.getText();
        }
    });
    connectionPanel.add(usernameTextField);
    usernameTextField.setColumns(8);
    lblpassword = new JLabel("Password");
    connectionPanel.add(lblpassword);
    passwordTextField = new JPasswordField();
    passwordTextField.addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            params.user = new String(passwordTextField.getPassword());
        }
    });
    connectionPanel.add(passwordTextField);
    passwordTextField.setColumns(8);
    lblnameSpace = new JLabel("Namespace");
    connectionPanel.add(lblnameSpace);
    namespaceTextField = new JTextField();
    namespaceTextField.addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            params.namespace = namespaceTextField.getText();
        }
    });
    connectionPanel.add(namespaceTextField);
    namespaceTextField.setColumns(8);
    lblSet = new JLabel("Set");
    connectionPanel.add(lblSet);
    txtSetTextfield = new JTextField();
    txtSetTextfield.addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            params.set = txtSetTextfield.getText();
        }
    });
    connectionPanel.add(txtSetTextfield);
    txtSetTextfield.setColumns(8);
    mainPanel.add(connectionPanel, BorderLayout.NORTH);
    examplePanel = new JPanel();
    examplePanel.setLayout(new BoxLayout(examplePanel, BoxLayout.Y_AXIS));
    exampleScrollPane = new JScrollPane(examplePanel);
    mainPanel.add(exampleScrollPane, BorderLayout.WEST);
    // init values
    seedHostTextField.setText(params.host);
    portTextField.setText(Integer.toString(params.port));
    namespaceTextField.setText(params.namespace);
    txtSetTextfield.setText(params.set);
    //int width = 785;
    int width = 1000;
    int height = 180;
    consoleTextArea = new JTextArea();
    consoleTextArea.setSize(new Dimension(width, height));
    consoleTextArea.setEditable(false);
    consoleScrollPane = new JScrollPane(consoleTextArea);
    consoleScrollPane.setPreferredSize(new Dimension(width, height));
    consoleScrollPane.setSize(new Dimension(width, height));
    splitPane.setRightComponent(consoleScrollPane);
    buttonGroup = new ButtonGroup();
    JRadioButton jrb;
    for (String example : Main.getAllExampleNames()) {
        jrb = new JRadioButton(example);
        jrb.setActionCommand(example);
        jrb.addActionListener(this);
        buttonGroup.add(jrb);
        examplePanel.add(jrb);
    }
    frmAerospikeExamples.pack();
}
Also used : JPanel(javax.swing.JPanel) FocusAdapter(java.awt.event.FocusAdapter) FlowLayout(java.awt.FlowLayout) JTextArea(javax.swing.JTextArea) JRadioButton(javax.swing.JRadioButton) KeyAdapter(java.awt.event.KeyAdapter) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField) FocusEvent(java.awt.event.FocusEvent) KeyEvent(java.awt.event.KeyEvent) Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) JScrollPane(javax.swing.JScrollPane) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) EtchedBorder(javax.swing.border.EtchedBorder) JPasswordField(javax.swing.JPasswordField) ButtonGroup(javax.swing.ButtonGroup) JSplitPane(javax.swing.JSplitPane)

Example 25 with KeyAdapter

use of java.awt.event.KeyAdapter in project intellij-community by JetBrains.

the class InspectionResultsView method initTreeListeners.

private void initTreeListeners() {
    if (ApplicationManager.getApplication().isUnitTestMode()) {
        return;
    }
    myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            if (myTree.isUnderQueueUpdate())
                return;
            syncRightPanel();
            if (isAutoScrollMode()) {
                OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(InspectionResultsView.this), false);
            }
        }
    });
    EditSourceOnDoubleClickHandler.install(myTree);
    myTree.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(InspectionResultsView.this), false);
            }
        }
    });
    PopupHandler.installPopupHandler(myTree, IdeActions.INSPECTION_TOOL_WINDOW_TREE_POPUP, ActionPlaces.CODE_INSPECTION);
    SmartExpander.installOn(myTree);
}
Also used : KeyEvent(java.awt.event.KeyEvent) KeyAdapter(java.awt.event.KeyAdapter) TreeSelectionListener(javax.swing.event.TreeSelectionListener) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent)

Aggregations

KeyAdapter (java.awt.event.KeyAdapter)70 KeyEvent (java.awt.event.KeyEvent)70 MouseEvent (java.awt.event.MouseEvent)26 MouseAdapter (java.awt.event.MouseAdapter)16 JPanel (javax.swing.JPanel)15 ActionEvent (java.awt.event.ActionEvent)14 JLabel (javax.swing.JLabel)14 ActionListener (java.awt.event.ActionListener)13 JButton (javax.swing.JButton)12 JScrollPane (javax.swing.JScrollPane)12 BorderLayout (java.awt.BorderLayout)11 JTextField (javax.swing.JTextField)11 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)11 TreePath (javax.swing.tree.TreePath)11 NotNull (org.jetbrains.annotations.NotNull)11 FlowLayout (java.awt.FlowLayout)10 Tree (com.intellij.ui.treeStructure.Tree)9 Dimension (java.awt.Dimension)8 ListSelectionEvent (javax.swing.event.ListSelectionEvent)7 ListSelectionListener (javax.swing.event.ListSelectionListener)7