A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Java
»
Swing / AWT / SWT
Author
about JScrollPane component
cat cater
Ranch Hand
Joined: Jun 06, 2005
Posts: 39
posted
Jun 06, 2005 03:27:00
0
默认情况下按�上,下,左,右�键可以使
JScrollPane
滚动,我想屏蔽这个功能该如何做啊
usually press "upkey,downkey,leftkey,rightkey" can scroll. I want to lost the function,how i od? thanks everyone.
cat cater
Ranch Hand
Joined: Jun 06, 2005
Posts: 39
posted
Jun 06, 2005 18:44:00
0
who can help me?
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
Jun 06, 2005 19:07:00
0
try this
import java.awt.*; import java.awt.event.KeyEvent; import javax.swing.*; class Testing extends JFrame { public Testing() { setLocation(400,300); setDefaultCloseOperation(EXIT_ON_CLOSE); JPanel jp = new JPanel(new GridLayout(50,1)); for(int x = 0; x < 50; x++) { jp.add(new JLabel("Label "+x+" with longggggggggggggg line")); jp.setFocusable(true);//labels need this, otherwise arrow keys will work } JScrollPane sp = new JScrollPane(jp); sp.setPreferredSize(new Dimension(100,150)); InputMap im = sp.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), "none"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), "none"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "none"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "none"); getContentPane().add(sp); pack(); } public static void main(String[] args){new Testing().setVisible(true);} }
cat cater
Ranch Hand
Joined: Jun 06, 2005
Posts: 39
posted
Jun 06, 2005 22:11:00
0
thanks Michael.
I agree. Here's the link:
http://aspose.com/file-tools
subject: about JScrollPane component
Similar Threads
NX: lock and unlock
Apache + Tomcat configuration
Wait Message
A question about jsp+javabean.
how to create a Properties Window?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter