Java Code Examples for javax.swing.JScrollPane#addMouseListener()
The following examples show how to use
javax.swing.JScrollPane#addMouseListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ETable.java From netbeans with Apache License 2.0 | 6 votes |
/** * This method update mouse listener on the scrollPane if it is needed. * It also recomputes the model of searchCombo. Both actions are needed after * the set of visible columns is changed. */ void updateColumnSelectionMouseListener() { Container p = getParent(); if (p instanceof JViewport) { Container gp = p.getParent(); if (gp instanceof JScrollPane) { JScrollPane scrollPane = (JScrollPane)gp; // Make certain we are the viewPort's view and not, for // example, the rowHeaderView of the scrollPane - // an implementor of fixed columns might do this. JViewport viewport = scrollPane.getViewport(); if (viewport == null || viewport.getView() != this) { return; } scrollPane.removeMouseListener(columnSelectionMouseListener); if (getColumnModel().getColumnCount() == 0) { scrollPane.addMouseListener(columnSelectionMouseListener); } } } if (searchCombo != null) { searchCombo.setModel(getSearchComboModel()); } }
Example 2
Source File: KeysTableView.java From pgptool with GNU General Public License v3.0 | 6 votes |
private JScrollPane initTableComponent() { table = new JTable(); // Adjust some visual appearence table.setRowHeight(22); table.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); // Add listeners selectionModel = new DefaultListSelectionModel(); selectionModel.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION); selectionModel.addListSelectionListener(rowSelectionListener); table.setSelectionModel(selectionModel); table.addMouseListener(listMouseListener); initTableKeyListener(); // Envelope in scrollpane scrollPane = new JScrollPane(); scrollPane.addMouseListener(listMouseListener); scrollPane.setViewportView(table); return scrollPane; }
Example 3
Source File: MainFrameView.java From pgptool with GNU General Public License v3.0 | 6 votes |
private JScrollPane initTableComponent() { table = new JTable(); // Adjust some visual appearence table.setRowHeight(22); // Add listeners selectionModel = new DefaultListSelectionModel(); selectionModel.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION); selectionModel.addListSelectionListener(rowSelectionListener); table.setSelectionModel(selectionModel); table.addMouseListener(listMouseListener); table.setDefaultRenderer(EncryptBackAction.class, new EncryptBackActionCellRenderer()); table.addMouseListener(encrBackClickHandler); initTableKeyListener(); // Envelope in scrollpane scrollPane = new JScrollPane(); scrollPane.addMouseListener(listMouseListener); scrollPane.setViewportView(table); return scrollPane; }
Example 4
Source File: Editor.java From i18n-editor with MIT License | 4 votes |
private void setupUI() { Color borderColor = Colors.scale(UIManager.getColor("Panel.background"), .8f); setTitle(TITLE); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new EditorWindowListener()); setIconImages(Lists.newArrayList("512","256","128","64","48","32","24","20","16").stream() .map(size -> Images.loadFromClasspath("images/icon-" + size + ".png").getImage()) .collect(Collectors.toList())); translationTree = new TranslationTree(); translationTree.setBorder(BorderFactory.createEmptyBorder(0,5,0,5)); translationTree.addTreeSelectionListener(new TranslationTreeNodeSelectionListener()); translationTree.addMouseListener(new TranslationTreeMouseListener()); translationField = new TranslationKeyField(); translationField.addKeyListener(new TranslationFieldKeyListener()); translationField.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createMatteBorder(1,0,0,1,borderColor), ((CompoundBorder)translationField.getBorder()).getInsideBorder())); JScrollPane translationsScrollPane = new JScrollPane(translationTree); translationsScrollPane.getViewport().setOpaque(false); translationsScrollPane.setOpaque(false); translationsScrollPane.setBorder(BorderFactory.createMatteBorder(0,0,0,1,borderColor)); translationsPanel = new JPanel(new BorderLayout()); translationsPanel.add(translationsScrollPane); translationsPanel.add(translationField, BorderLayout.SOUTH); resourcesPanel = new JScrollablePanel(true, false); resourcesPanel.setLayout(new BoxLayout(resourcesPanel, BoxLayout.Y_AXIS)); resourcesPanel.setBorder(BorderFactory.createEmptyBorder(10,20,10,20)); resourcesPanel.setOpaque(false); resourcesPanel.addMouseListener(new ResourcesPaneMouseListener()); resourcesScrollPane = new JScrollPane(resourcesPanel); resourcesScrollPane.getViewport().setOpaque(false); resourcesScrollPane.setOpaque(false); resourcesScrollPane.setBorder(null); resourcesScrollPane.addMouseListener(new ResourcesPaneMouseListener()); contentPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, translationsPanel, resourcesScrollPane); contentPane.setBorder(null); contentPane.setDividerSize(10); // Style the split pane divider if possible SplitPaneUI splitPaneUI = contentPane.getUI(); if (splitPaneUI instanceof BasicSplitPaneUI) { BasicSplitPaneDivider divider = ((BasicSplitPaneUI)splitPaneUI).getDivider(); divider.setBorder(null); resourcesPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,20)); } introText = new JLabel("<html><body style=\"text-align:center; padding:30px;\">" + MessageBundle.get("core.intro.text") + "</body></html>"); introText.setOpaque(true); introText.setFont(introText.getFont().deriveFont(28f)); introText.setHorizontalTextPosition(JLabel.CENTER); introText.setVerticalTextPosition(JLabel.BOTTOM); introText.setHorizontalAlignment(JLabel.CENTER); introText.setVerticalAlignment(JLabel.CENTER); introText.setForeground(getBackground().darker()); introText.setIcon(Images.loadFromClasspath("images/icon-intro.png")); Container container = getContentPane(); container.add(introText); editorMenu = new EditorMenuBar(this, translationTree); setJMenuBar(editorMenu); }