1. Component in a JScrollPane stops receiving KeyEvents stackoverflow.comI am putting a component ( derivative on JPanel ) inside a JScrollPane.
since the component occasionally changes size, I have to occasionally do :
|
2. Java -- How to set the keyboard scroll speed for a JScrollPane stackoverflow.comA |
3. adding keyevents to scrollbars coderanch.com |
4. JScrollBar, key events coderanch.comimport 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.comHi, 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 |