请教java程序中组合键的使用 比如想实现Ctrl+Enter发送文本框中的内容,如何实现? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://hi.baidu.com/beanchx/blog/item/230e31fa0321031fa8d31183.html public class Test extends JFrame implements KeyListener{ JTextArea jt1,jt2; public Test(){ this.setSize(250,200); Container con = this.getContentPane(); JPanel jp = new JPanel(); jp.setLayout(new BorderLayout()); jt1 = new JTextArea(); jt1.setEnabled(false); jt1.setBackground(Color.lightGray); jt2 = new JTextArea(); jt2.addKeyListener(this); jp.add(jt1,BorderLayout.CENTER); jp.add(jt2,BorderLayout.SOUTH); con.add(jp); this.setLocation(100,100); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); //this.pack(); } public void keyTyped(KeyEvent e){ if(e.getKeyChar()== e.VK_ENTER){ jt1.setText(jt2.getText()); jt2.setText(""); } } public void keyReleased(KeyEvent e){} public void keyPressed(KeyEvent e){} public static void main(String[] args){ new Test(); }} 懂jfreechart的进 jdic安装时怎样修改环境变量呀 有个问题没明白请大家帮忙 java如何实现QQ菜单效果 如何动态的添加和删除控件? java中如何取得请求时用户输入的地址 怎么把获取的系统文件添加到JTree 关于JOptionPane国际化问题! helping 关于javaAPI中接口中方法实现的理解 为什么要改写java中Object类的equals方法 Java中如何把非系统时间HH:mm或yyyy-MM-dd HH:mm插入到SQL中
JTextArea jt1,jt2;
public Test(){
this.setSize(250,200);
Container con = this.getContentPane();
JPanel jp = new JPanel();
jp.setLayout(new BorderLayout());
jt1 = new JTextArea();
jt1.setEnabled(false);
jt1.setBackground(Color.lightGray);
jt2 = new JTextArea();
jt2.addKeyListener(this);
jp.add(jt1,BorderLayout.CENTER);
jp.add(jt2,BorderLayout.SOUTH);
con.add(jp);
this.setLocation(100,100);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
//this.pack();
}
public void keyTyped(KeyEvent e){
if(e.getKeyChar()== e.VK_ENTER){
jt1.setText(jt2.getText());
jt2.setText("");
}
}
public void keyReleased(KeyEvent e){}
public void keyPressed(KeyEvent e){}
public static void main(String[] args){
new Test();
}
}