How can I simulate combination keystrokes event ?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Wang_Yang
Posted On:   Thursday, September 11, 2003 01:26 AM

How can I simulate key combination event ?that is to say ,I send a key combination event to the os (e.g.ctrl+shift+del )
and in the former questions there is a similar one ,but it just solve the one-key strike simulation not combination.


Please use html tags to format code blocks.

SOLUTION for "How can I simulate combination keystrokes event?"

Posted By:   Anonymous  
Posted On:   Thursday, October 16, 2003 05:34 AM

import java.awt.*;

import java.awt.event.*;

import java.applet.*;



//



public class TextAreaTest extends Applet implements ActionListener

{

TextArea a = new TextArea("Vijay",5,20,TextArea.SCROLLBARS_VERTICAL_ONLY);

TextArea b = new TextArea("Vijay",5,20,TextArea.SCROLLBARS_VERTICAL_ONLY);

Button c = new Button("Click");

Panel p = new Panel();





public void init()

{

setLayout(null);

p.setLayout(new GridLayout(1,3));

p.add(a);

p.add(b);

p.add(c);

p.setSize(400,100);

a.setEditable(false);

add(p);

//a.setWordWrap(false);

c.addActionListener(this);





b.addKeyListener(

new KeyAdapter()

{

public void keyPressed(KeyEvent ke )

{

if (ke.getKeyCode()==KeyEvent.VK_C && ke.isControlDown() && ke.isAltDown())

{

a.setText("");b.setText("");

a.setText("Control + C Pressed");

b.setText("Control + C Pressed");

}



}

}

);

}



public void start()

{

}



public void stop()

{

}



public void destroy()

{

}



public void paint(Graphics g)

{

}



public void actionPerformed(ActionEvent ae)

{





if (ae.getActionCommand() == "Click")

{

a.appendText(b.getText()+"Vijay");

b.setText("");

a.setCaretPosition(a.getText().length() - 1);

}

}

}





I hope so that this prgm will help you to handle
multiple key events.


with love Vijay

About | Sitemap | Contact