OSDN Git Service

ツイートを投稿するテキストボックス部分を右クリックしても,切り取り,張り付け等のウィンドウが表示されない問題を解決 refs #23798
authorspark_xp <spark_xp@d8c9ecd3-d47d-4367-8645-de82c00e513f>
Sat, 28 May 2011 09:29:58 +0000 (09:29 +0000)
committerspark_xp <spark_xp@d8c9ecd3-d47d-4367-8645-de82c00e513f>
Sat, 28 May 2011 09:29:58 +0000 (09:29 +0000)
git-svn-id: http://svn.sourceforge.jp/svnroot/nt-manager/NishioTweetManager/trunk@145 d8c9ecd3-d47d-4367-8645-de82c00e513f

src/twitter/gui/component/TweetTextFieldPopupMenu.java [new file with mode: 0644]
src/twitter/gui/form/NishioTweetManager.java

diff --git a/src/twitter/gui/component/TweetTextFieldPopupMenu.java b/src/twitter/gui/component/TweetTextFieldPopupMenu.java
new file mode 100644 (file)
index 0000000..75558d2
--- /dev/null
@@ -0,0 +1,48 @@
+package twitter.gui.component;
+
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JEditorPane;
+import javax.swing.JPopupMenu;
+import javax.swing.JTextField;
+import javax.swing.text.DefaultEditorKit;
+
+/**
+ * Tweetボックスの右クリックに対応
+ * @author nishio
+ *
+ */
+public class TweetTextFieldPopupMenu extends JPopupMenu {
+       private JEditorPane field = null;
+       private final Action cutAction = new DefaultEditorKit.CutAction();
+       private final Action copyAction = new DefaultEditorKit.CopyAction();
+       private final Action pasteAction = new DefaultEditorKit.PasteAction();
+       
+       public TweetTextFieldPopupMenu(JEditorPane field) {
+               super();
+               this.field = field;
+               
+               cutAction.putValue(Action.NAME, "切り取り");
+               copyAction.putValue(Action.NAME, "コピー");
+               pasteAction.putValue(Action.NAME, "貼り付け");
+               add(cutAction);
+               add(copyAction);
+               add(pasteAction);
+               this.field.add( this );
+       }
+       
+       /**
+        * 
+        */
+       public void show(Component c, int x, int y) {
+               JEditorPane field = (JEditorPane) c;
+               boolean flg = field.getSelectedText() != null;
+               cutAction.setEnabled(flg);
+               copyAction.setEnabled(flg);
+               super.show(c, x, y);
+       }
+
+}
index b0d2867..6033d44 100644 (file)
@@ -38,6 +38,7 @@ import twitter.action.list.ListGetterSelection;
 import twitter.gui.action.TweetMainAction;
 import twitter.gui.component.TweetHashtagHyperlinkHandler;
 import twitter.gui.component.TweetHyperlinkHandler;
+import twitter.gui.component.TweetTextFieldPopupMenu;
 import twitter.manage.TweetManager;
 import twitter.task.TimerID;
 
@@ -126,6 +127,10 @@ public class NishioTweetManager extends javax.swing.JFrame {
                } catch (AWTException e) {
                        e.printStackTrace();
                }
+               
+               //tweet発言するボックスの右クリック対応
+               this.jTextPane.setComponentPopupMenu(
+                               new TweetTextFieldPopupMenu( this.jTextPane ) );
        }
 
        /**