快速业务通道

Swing嶄葎猟云怏周協崙由匯議暇汽 - 園殻秘壇利

作者 佚名技术 来源 NET编程 浏览 发布时间 2012-06-21

Swing嶄葎猟云怏周協崙由匯議暇汽

扮寂:2011-01-16 BlogJava kissjava

壓載謹罷周嶄耽倖猟云怏周脅嗤徭協吶議暇汽,宸倖blogjava議園辞匂祥嗤宸劔議暇汽泌?Cut , Copy,Paste,Delete,Select All?壓Swing嶄飛匆?壓JTextField,JTextArea,JEditorPane,JTextPane吉吉宸乂怏周嶄脅戻工泌緩徭協吶暇汽議孔嬬?耽倖脅亟写覚窃?賜宀紗報炎酌油並周?徽音砿奕劔的脅氏糞?丼惚?峪音狛宸劔強床載寄?音挫略擦?書爺壓利貧心欺匯倖載頁圭宴議圭隈。

寄社脅岑祇?Swing嶄侭嗤議並周脅頁序秘java.awt.EventQueue宸倖錦双嶄吉棋?隼朔宥狛dispatchEvent圭隈序佩塗窟?椎担厘断壓宸戦祥亟倖写覚EventQueue宸倖窃?盛舜侭嗤議並周旺斤凪序佩侃尖?厘断議猟云怏周脅頁写覚嚥JTextComponent議?椎担欺宸戦厘断祥嬬葎侭嗤議猟云怏周協崙匯崑議暇汽阻。丼惚泌?

需旗鷹?

package org.kissjava.swingx.core; import java.awt.AWTEvent; import java.awt.Component; import java.awt.EventQueue; import java.awt.Point; import java.awt.Toolkit; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.event.ActionEvent; import java.awt.event.MouseEvent; import javax.swing.AbstractAction; import javax.swing.JPopupMenu; import javax.swing.MenuSelectionManager; import javax.swing.SwingUtilities; import javax.swing.text.JTextComponent; public class KJEventQueue extends EventQueue {      @Override       protected void dispatchEvent(AWTEvent event){              super.dispatchEvent(event);              // interested only in mouseevents              if(!(event instanceof MouseEvent))                  return;              MouseEvent me = (MouseEvent)event;              // interested only in popuptriggers              if(!me.isPopupTrigger())                  return;              // me.getComponent() retunrs the heavy weight component on which event occured              Component comp = SwingUtilities.getDeepestComponentAt(me.getComponent(), me.getX(), me.getY());              // interested only in textcomponents              if(!(comp instanceof JTextComponent))                  return;              // no popup shown by user code              if(MenuSelectionManager.defaultManager().getSelectedPath().length>0)                  return;              // create popup menu and show               JTextComponent tc = (JTextComponent)comp;              JPopupMenu menu = new JPopupMenu();              menu.add(new CutAction(tc));              menu.add(new CopyAction(tc));              menu.add(new PasteAction(tc));              menu.add(new DeleteAction(tc));              menu.addSeparator();              menu.add(new SelectAllAction(tc));              Point pt = SwingUtilities.convertPoint(me.g

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号