Key « JScrollPane « Java Swing Q&A





1. Component in a JScrollPane stops receiving KeyEvents    stackoverflow.com

I am putting a component ( derivative on JPanel ) inside a JScrollPane.

scrollPane = new JScrollPane(component);
since the component occasionally changes size, I have to occasionally do :
 SwingUtilities.invokeLater(new Runnable(){

   ...

2. Java -- How to set the keyboard scroll speed for a JScrollPane    stackoverflow.com

A JPanel has a JScrollPane that contains yet another JPanel or two. My life depends on increasing the scroll speed using a keyboard's directional arrows. After careful deliberation, the powers that ...

3. adding keyevents to scrollbars    coderanch.com

4. JScrollBar, key events    coderanch.com

import java.awt.*; import java.awt.event.*; import javax.swing.*; public class myFrame extends JFrame { JPanel panel1; public myFrame() { panel1 = new JPanel(); panel1.setLayout(null); panel1.setBackground(Color.red); JScrollBar sb = new JScrollBar(JScrollBar.HORIZONTAL, 1, 20, 0, 100); sb.setSize(new Dimension(191, 17)); this.setContentPane(panel1); panel1.add(sb); // bind keystrokes to your content pane panel1.getInputMap().put(KeyStroke.getKeyStroke("ESCAPE"), "ESCAPE"); panel1.getActionMap().put("ESCAPE", escape); panel1.getInputMap().put(KeyStroke.getKeyStroke("SPACE"), "SPACE"); panel1.getActionMap().put("SPACE", space); } private Action escape = new AbstractAction() { public ...

5. Select multiple items in JScrollpane while pressing Control Key    coderanch.com

Hi, yes u can select muliple items using cntrl or shift keys by getting the selected items of the list and iterating them ,like this... ......Code......... Object obj[] = List.getSelectedValues(); int length = List.getSelectedValues().length; if (length != -1) { for (int i = 0; i < length; i++) { ///ur logic } } Bbye