Search in sources :

Example 81 with MouseAdapter

use of java.awt.event.MouseAdapter 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 82 with MouseAdapter

use of java.awt.event.MouseAdapter in project cayenne by apache.

the class BaseGraphBuilder method addMouseListeners.

private void addMouseListeners() {
    graph.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseReleased(MouseEvent e) {
            if (e.isPopupTrigger()) {
                Object selected = graph.getSelectionCell();
                if (selected != null && selected instanceof DefaultGraphCell) {
                    Object userObject = ((DefaultGraphCell) selected).getUserObject();
                    if (userObject instanceof EntityCellMetadata) {
                        showPopup(e.getPoint(), ((EntityCellMetadata) userObject).fetchEntity());
                    }
                }
            }
        }
    });
    graph.addMouseWheelListener(e -> {
        // limit scale
        double scale = graph.getScale() / Math.pow(ZOOM_FACTOR, e.getWheelRotation());
        scale = Math.max(scale, 0.1);
        scale = Math.min(scale, 3);
        graph.setScale(scale);
    });
}
Also used : MouseEvent(java.awt.event.MouseEvent) DefaultGraphCell(org.jgraph.graph.DefaultGraphCell) MouseAdapter(java.awt.event.MouseAdapter)

Example 83 with MouseAdapter

use of java.awt.event.MouseAdapter in project jPOS by jpos.

the class ISOMeter method createLogList.

public JComponent createLogList() {
    final JList logList = new JList(parent.getLog());
    JPanel A = new JPanel();
    A.setLayout(new BorderLayout());
    MouseListener mouseListener = new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            ISOMsg m = (ISOMsg) logList.getSelectedValue();
            if (m != null) {
                JFrame f = new JFrame(parent.getSymbolicName() + ":" + m.toString());
                ISOMsgPanel p = new ISOMsgPanel(m);
                f.getContentPane().add(p);
                f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                f.pack();
                f.show();
            }
        }
    };
    logList.addMouseListener(mouseListener);
    logList.setPrototypeCellValue("9999 99999999 999999");
    JScrollPane scrollPane = new JScrollPane(logList);
    A.add(scrollPane, BorderLayout.CENTER);
    return A;
}
Also used : MouseListener(java.awt.event.MouseListener) MouseEvent(java.awt.event.MouseEvent) ISOMsg(org.jpos.iso.ISOMsg) MouseAdapter(java.awt.event.MouseAdapter)

Example 84 with MouseAdapter

use of java.awt.event.MouseAdapter in project knime-core by knime.

the class JSnippetPanel method initComponents.

private void initComponents() {
    m_colList = new JList(new DefaultListModel());
    m_colList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    m_colList.addKeyListener(new KeyAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void keyTyped(final KeyEvent e) {
            if (e.getKeyChar() == KeyEvent.VK_ENTER) {
                Object selected = m_colList.getSelectedValue();
                if (selected != null) {
                    onSelectionInColumnList(selected);
                }
            }
        }
    });
    m_colList.addMouseListener(new MouseAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void mouseClicked(final MouseEvent e) {
            if (e.getClickCount() == 2) {
                Object selected = m_colList.getSelectedValue();
                if (selected != null) {
                    onSelectionInColumnList(selected);
                }
            }
        }
    });
    m_colList.setCellRenderer(new ListRenderer());
    m_flowVarsList = new JList(new DefaultListModel());
    m_flowVarsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    // enable tooltip
    m_flowVarsList.setToolTipText("");
    m_flowVarsList.addKeyListener(new KeyAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void keyTyped(final KeyEvent e) {
            if (e.getKeyChar() == KeyEvent.VK_ENTER) {
                Object selected = m_flowVarsList.getSelectedValue();
                if (selected != null) {
                    onSelectionInVariableList(selected);
                }
            }
        }
    });
    m_flowVarsList.addMouseListener(new MouseAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void mouseClicked(final MouseEvent e) {
            if (e.getClickCount() == 2) {
                Object selected = m_flowVarsList.getSelectedValue();
                if (selected != null) {
                    onSelectionInVariableList(selected);
                }
            }
        }
    });
    m_flowVarsList.setCellRenderer(new FlowVariableListCellRenderer());
    m_categories = new JComboBox(m_manipProvider.getCategories().toArray());
    m_categories.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            JComboBox cb = (JComboBox) e.getSource();
            String category = (String) cb.getSelectedItem();
            updateManipulatorList(category);
        }
    });
    m_manipulators = new JList(new DefaultListModel());
    m_manipulators.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    m_manipulators.setCellRenderer(new ManipulatorListCellRenderer());
    m_manipulators.addKeyListener(new KeyAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void keyTyped(final KeyEvent e) {
            if (e.getKeyChar() == KeyEvent.VK_ENTER) {
                Object selected = m_manipulators.getSelectedValue();
                if (selected != null) {
                    onSelectionInManipulatorList(selected);
                }
            }
        }
    });
    m_manipulators.addMouseListener(new MouseAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void mouseClicked(final MouseEvent e) {
            if (e.getClickCount() == 2) {
                Object selected = m_manipulators.getSelectedValue();
                if (selected != null) {
                    onSelectionInManipulatorList(selected);
                }
            }
        }
    });
    m_manipulators.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(final ListSelectionEvent e) {
            Object selected = m_manipulators.getSelectedValue();
            if (selected != null) {
                Manipulator manipulator = (Manipulator) selected;
                m_description.setText(manipulator.getDescription());
                m_description.setCaretPosition(0);
            } else {
                m_description.setText("");
            }
        }
    });
    HTMLEditorKit kit = new HTMLEditorKit();
    StyleSheet css = new StyleSheet();
    css.addRule("* { font-family: sans-serif; }");
    kit.setStyleSheet(css);
    m_description = new JTextPane();
    m_description.setEditorKit(kit);
    m_description.setEditable(false);
    m_description.setBackground(getBackground());
    updateManipulatorList(ManipulatorProvider.ALL_CATEGORY);
    initSubComponents();
}
Also used : MouseEvent(java.awt.event.MouseEvent) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) KeyAdapter(java.awt.event.KeyAdapter) MouseAdapter(java.awt.event.MouseAdapter) ListSelectionEvent(javax.swing.event.ListSelectionEvent) DefaultListModel(javax.swing.DefaultListModel) HTMLEditorKit(javax.swing.text.html.HTMLEditorKit) ListSelectionListener(javax.swing.event.ListSelectionListener) Manipulator(org.knime.base.node.preproc.stringmanipulation.manipulator.Manipulator) KeyEvent(java.awt.event.KeyEvent) FlowVariableListCellRenderer(org.knime.core.node.util.FlowVariableListCellRenderer) JTextPane(javax.swing.JTextPane) StyleSheet(javax.swing.text.html.StyleSheet) ActionListener(java.awt.event.ActionListener) JList(javax.swing.JList)

Example 85 with MouseAdapter

use of java.awt.event.MouseAdapter in project knime-core by knime.

the class TimeMissingValueHandlingNodeDialogPane method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
    m_searchableListModifier = m_searchableListPanel.update(specs[0]);
    TimeMissingValueHandlingColSetting[] defaults = TimeMissingValueHandlingColSetting.loadMetaColSettings(settings, specs[0]);
    TimeMissingValueHandlingColSetting[] individuals = TimeMissingValueHandlingColSetting.loadIndividualColSettings(settings, specs[0]);
    m_defaultsPanel.removeAll();
    for (int i = 0; i < defaults.length; i++) {
        final TimeMissingValueHandlingPanel p = new TimeMissingValueHandlingPanel(defaults[i], (DataColumnSpec) null);
        m_defaultsPanel.add(p);
    }
    m_individualsPanel.removeAll();
    Set<String> invalidColumns = new LinkedHashSet<String>();
    for (int i = 0; i < individuals.length; i++) {
        String[] names = individuals[i].getNames();
        ArrayList<DataColumnSpec> colSpecs = new ArrayList<DataColumnSpec>();
        for (int j = 0; j < names.length; j++) {
            final DataColumnSpec cspec = specs[0].getColumnSpec(names[j]);
            if (cspec == null) {
                LOGGER.debug("No such column in spec: " + names[j]);
                DataColumnSpec createUnkownSpec = createUnkownSpec(names[j], individuals[i]);
                colSpecs.add(createUnkownSpec);
                invalidColumns.add(names[j]);
            } else {
                colSpecs.add(cspec);
            }
        }
        if (!colSpecs.isEmpty()) {
            names = new String[colSpecs.size()];
            for (int j = 0; j < names.length; j++) {
                names[j] = colSpecs.get(j).getName();
            }
            individuals[i].setNames(names);
            markIncompatibleTypedColumns(individuals[i].getType(), colSpecs);
            final TimeMissingValueHandlingPanel p = new TimeMissingValueHandlingPanel(individuals[i], colSpecs.toArray(new DataColumnSpec[0]));
            p.registerMouseListener(new MouseAdapter() {

                /**
                 * {@inheritDoc}
                 */
                @Override
                public void mouseClicked(final MouseEvent me) {
                    selectColumns(p.getSettings());
                }
            });
            addToIndividualPanel(p);
        }
    }
    m_searchableListModifier.addInvalidColumns(invalidColumns.toArray(new String[invalidColumns.size()]));
    m_individualsPanel.setPreferredSize(m_defaultsPanel.getPreferredSize());
    checkButtonStatus();
}
Also used : LinkedHashSet(java.util.LinkedHashSet) MouseEvent(java.awt.event.MouseEvent) ArrayList(java.util.ArrayList) MouseAdapter(java.awt.event.MouseAdapter) DataColumnSpec(org.knime.core.data.DataColumnSpec)

Aggregations

MouseAdapter (java.awt.event.MouseAdapter)202 MouseEvent (java.awt.event.MouseEvent)199 JLabel (javax.swing.JLabel)52 JPanel (javax.swing.JPanel)48 ActionEvent (java.awt.event.ActionEvent)36 JScrollPane (javax.swing.JScrollPane)36 BorderLayout (java.awt.BorderLayout)35 Dimension (java.awt.Dimension)34 JButton (javax.swing.JButton)33 ActionListener (java.awt.event.ActionListener)32 Insets (java.awt.Insets)24 GridBagConstraints (java.awt.GridBagConstraints)20 KeyEvent (java.awt.event.KeyEvent)20 KeyAdapter (java.awt.event.KeyAdapter)19 JTextField (javax.swing.JTextField)16 ListSelectionEvent (javax.swing.event.ListSelectionEvent)16 Component (java.awt.Component)15 Point (java.awt.Point)15 JTable (javax.swing.JTable)15 ListSelectionListener (javax.swing.event.ListSelectionListener)15