Search in sources :

Example 96 with MouseEvent

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

the class AddEditRemovePanel method initTable.

private void initTable() {
    myTableModel = new AbstractTableModel() {

        public int getColumnCount() {
            return myModel.getColumnCount();
        }

        public int getRowCount() {
            return myData != null ? myData.size() : 0;
        }

        public Class getColumnClass(int columnIndex) {
            return myModel.getColumnClass(columnIndex);
        }

        public String getColumnName(int column) {
            return myModel.getColumnName(column);
        }

        public Object getValueAt(int rowIndex, int columnIndex) {
            return myModel.getField(myData.get(rowIndex), columnIndex);
        }

        @Override
        public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
            myModel.setValue(aValue, myData.get(rowIndex), columnIndex);
            fireTableRowsUpdated(rowIndex, rowIndex);
        }

        @Override
        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return myModel.isEditable(columnIndex);
        }
    };
    myTable = createTable();
    myTable.setModel(myTableModel);
    myTable.setShowColumns(false);
    myTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    myTable.setStriped(true);
    new DoubleClickListener() {

        @Override
        protected boolean onDoubleClick(MouseEvent event) {
            doEdit();
            return true;
        }
    }.installOn(myTable);
}
Also used : MouseEvent(java.awt.event.MouseEvent) AbstractTableModel(javax.swing.table.AbstractTableModel)

Example 97 with MouseEvent

use of java.awt.event.MouseEvent in project jadx by skylot.

the class TabbedPane method makeTabComponent.

private Component makeTabComponent(final ContentPanel contentPanel) {
    JNode node = contentPanel.getNode();
    String name = node.makeLongString();
    final JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 3, 0));
    panel.setOpaque(false);
    final JLabel label = new JLabel(name);
    label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
    label.setIcon(node.getIcon());
    final JButton button = new JButton();
    button.setIcon(ICON_CLOSE_INACTIVE);
    button.setRolloverIcon(ICON_CLOSE);
    button.setRolloverEnabled(true);
    button.setOpaque(false);
    button.setUI(new BasicButtonUI());
    button.setContentAreaFilled(false);
    button.setFocusable(false);
    button.setBorder(null);
    button.setBorderPainted(false);
    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            closeCodePanel(contentPanel);
        }
    });
    panel.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isMiddleMouseButton(e)) {
                closeCodePanel(contentPanel);
            } else if (SwingUtilities.isRightMouseButton(e)) {
                JPopupMenu menu = createTabPopupMenu(contentPanel);
                menu.show(panel, e.getX(), e.getY());
            } else {
                // TODO: make correct event delegation to tabbed pane
                setSelectedComponent(contentPanel);
            }
        }
    });
    panel.add(label);
    panel.add(button);
    panel.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));
    return panel;
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) MouseEvent(java.awt.event.MouseEvent) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) BasicButtonUI(javax.swing.plaf.basic.BasicButtonUI) JPopupMenu(javax.swing.JPopupMenu) ActionListener(java.awt.event.ActionListener) JNode(jadx.gui.treemodel.JNode)

Example 98 with MouseEvent

use of java.awt.event.MouseEvent in project jadx by skylot.

the class JadxSettingsWindow method makeEditorGroup.

private SettingsGroup makeEditorGroup() {
    JButton fontBtn = new JButton(NLS.str("preferences.select_font"));
    fontBtn.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            JFontChooser fontChooser = new JFontChooser();
            fontChooser.setSelectedFont(settings.getFont());
            int result = fontChooser.showDialog(JadxSettingsWindow.this);
            if (result == JFontChooser.OK_OPTION) {
                Font font = fontChooser.getSelectedFont();
                LOG.info("Selected Font : {}", font);
                settings.setFont(font);
                mainWindow.updateFont(font);
            }
        }
    });
    SettingsGroup other = new SettingsGroup(NLS.str("preferences.editor"));
    other.addRow(NLS.str("preferences.font"), fontBtn);
    return other;
}
Also used : MouseEvent(java.awt.event.MouseEvent) JFontChooser(say.swing.JFontChooser) JButton(javax.swing.JButton) MouseAdapter(java.awt.event.MouseAdapter) Font(java.awt.Font)

Example 99 with MouseEvent

use of java.awt.event.MouseEvent in project libgdx by libgdx.

the class ExternalExtensionsDialog method uiLayout.

private void uiLayout() {
    topPanel = new JPanel(new GridBagLayout());
    topPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    warningNotice = new JLabel("List of third party extensions for LibGDX");
    warningNotice2 = new JLabel("These are not maintained by the LibGDX team, please see the support links for info and help");
    warningNotice.setHorizontalAlignment(JLabel.CENTER);
    warningNotice2.setHorizontalAlignment(JLabel.CENTER);
    topPanel.add(warningNotice, new GridBagConstraints(0, 0, 1, 1, 1, 0, NORTH, HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    topPanel.add(warningNotice2, new GridBagConstraints(0, 1, 1, 1, 1, 0, NORTH, HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    JSeparator separator = new JSeparator();
    separator.setForeground(new Color(85, 85, 85));
    separator.setBackground(new Color(85, 85, 85));
    topPanel.add(separator, new GridBagConstraints(0, 2, 1, 1, 1, 1, NORTH, HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    tableModel = new ExtensionTableModel();
    table = new JTable(tableModel) {

        @Override
        public String getToolTipText(MouseEvent e) {
            return ((ExtensionTableModel) getModel()).getToolTip(e);
        }
    };
    table.getColumnModel().getColumn(0).setPreferredWidth(10);
    table.getColumnModel().getColumn(1).setPreferredWidth(50);
    table.getColumnModel().getColumn(2).setPreferredWidth(100);
    table.getColumnModel().getColumn(3).setPreferredWidth(20);
    table.getColumnModel().getColumn(4).setPreferredWidth(30);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    table.getTableHeader().setReorderingAllowed(false);
    table.getModel().addTableModelListener(this);
    table.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            int row = table.getSelectedRow();
            int column = table.getSelectedColumn();
            if (column == 5) {
                URI uri = ((ExtensionTableModel) table.getModel()).getURI(row, column);
                if (uri != null) {
                    try {
                        Desktop.getDesktop().browse(uri);
                    } catch (IOException e1) {
                        e1.printStackTrace();
                    }
                }
            }
        }
    });
    scrollPane = new JScrollPane(table);
    bottomPanel = new JPanel(new GridBagLayout());
    buttonPanel = new JPanel(new GridBagLayout());
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    buttonOK = new SetupButton("Save");
    buttonCancel = new SetupButton("Cancel");
    buttonPanel.add(buttonOK, new GridBagConstraints(0, 0, 1, 1, 0, 0, CENTER, HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    buttonPanel.add(buttonCancel, new GridBagConstraints(1, 0, 1, 1, 0, 0, CENTER, HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    bottomPanel.add(buttonPanel, new GridBagConstraints(3, 0, 1, 1, 1, 1, SOUTHEAST, NONE, new Insets(0, 0, 0, 0), 0, 0));
    contentPane.add(topPanel, new GridBagConstraints(0, 0, 1, 1, 1, 0.1, NORTH, BOTH, new Insets(0, 0, 0, 0), 0, 0));
    contentPane.add(scrollPane, new GridBagConstraints(0, 1, 1, 1, 1, 1, NORTH, BOTH, new Insets(0, 0, 0, 0), 0, 0));
    contentPane.add(bottomPanel, new GridBagConstraints(0, 2, 1, 1, 1, 0, SOUTH, HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    try {
        initData();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) MouseEvent(java.awt.event.MouseEvent) SetupButton(com.badlogic.gdx.setup.GdxSetupUI.SetupButton) GridBagLayout(java.awt.GridBagLayout) Color(java.awt.Color) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) IOException(java.io.IOException) URI(java.net.URI) JSeparator(javax.swing.JSeparator) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException) JTable(javax.swing.JTable)

Example 100 with MouseEvent

use of java.awt.event.MouseEvent in project libgdx by libgdx.

the class EditorPanel method initializeComponents.

protected void initializeComponents() {
    setLayout(new GridBagLayout());
    {
        titlePanel = new JPanel(new GridBagLayout());
        add(titlePanel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(3, 0, 3, 0), 0, 0));
        titlePanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        {
            nameLabel = new JLabel(name);
            titlePanel.add(nameLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 6, 3, 6), 0, 0));
            nameLabel.setFont(nameLabel.getFont().deriveFont(Font.BOLD));
        }
        {
            descriptionLabel = new JLabel(description);
            titlePanel.add(descriptionLabel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 6, 3, 6), 0, 0));
        }
        {
            advancedButton = new JToggleButton("Advanced");
            titlePanel.add(advancedButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
            advancedButton.setVisible(false);
        }
        {
            activeButton = new JToggleButton("Active");
            titlePanel.add(activeButton, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
        }
        {
            removeButton = new JButton("X");
            titlePanel.add(removeButton, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
        }
    }
    {
        contentPanel = new JPanel(new GridBagLayout());
        add(contentPanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 6, 6, 6), 0, 0));
        contentPanel.setVisible(false);
    }
    {
        advancedPanel = new JPanel(new GridBagLayout());
        add(advancedPanel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 6, 6, 6), 0, 0));
        advancedPanel.setVisible(false);
    }
    titlePanel.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent event) {
            if (!isAlwaysShown)
                showContent(!contentPanel.isVisible());
        }
    });
    activeButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            activate();
        }
    });
    advancedButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            advancedPanel.setVisible(advancedButton.isSelected());
        }
    });
    removeButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            removePanel();
        }
    });
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) MouseEvent(java.awt.event.MouseEvent) GridBagLayout(java.awt.GridBagLayout) JToggleButton(javax.swing.JToggleButton) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel)

Aggregations

MouseEvent (java.awt.event.MouseEvent)918 MouseAdapter (java.awt.event.MouseAdapter)595 Dimension (java.awt.Dimension)183 JPanel (javax.swing.JPanel)174 ActionEvent (java.awt.event.ActionEvent)172 JLabel (javax.swing.JLabel)169 Point (java.awt.Point)143 ActionListener (java.awt.event.ActionListener)123 BorderLayout (java.awt.BorderLayout)119 JScrollPane (javax.swing.JScrollPane)113 JButton (javax.swing.JButton)109 KeyEvent (java.awt.event.KeyEvent)85 ChangeEvent (javax.swing.event.ChangeEvent)85 ChangeListener (javax.swing.event.ChangeListener)83 Insets (java.awt.Insets)79 MouseListener (java.awt.event.MouseListener)72 KeyAdapter (java.awt.event.KeyAdapter)65 JPopupMenu (javax.swing.JPopupMenu)64 JSlider (javax.swing.JSlider)63 GridBagConstraints (java.awt.GridBagConstraints)62