r***@L-3com.com
2014-04-09 03:10:23 UTC
I can't figure out what I'm doing wrong here. The Java code works. All the Ruby permutations return nil. How can I get the names I want?
Thanks!
=== deleteme.java ===
import java.io.*;
import javax.swing.*;
class Deleteme {
public static void main(String args[]) throws IOException {
String str;
str = (String)TransferHandler.getCutAction().getValue(Action.NAME);
System.out.println("Cut action name is: " + str);
str = (String)TransferHandler.getCopyAction().getValue(Action.NAME);
System.out.println("Copy action name is: " + str);
str = (String)TransferHandler.getPasteAction().getValue(Action.NAME);
System.out.println("Paste action name is: " + str);
}
}
=== END deleteme.java ===
$ javac deleteme.java
$ java Deleteme
Cut action name is: cut
Copy action name is: copy
Paste action name is: paste
=== deleteme.rb ===
require 'java'
# Easier way to do this at file scope? Normally I would just include_package
# 'javax.swing' in my class.
java_import javax.swing.TransferHandler
java_import javax.swing.Action
name = TransferHandler.getCutAction.getValue(Action.NAME)
puts "Cut action name is: #{name}"
name = TransferHandler.getCopyAction.getValue(Action.NAME)
puts "Copy action name is: #{name}"
name = TransferHandler.getPasteAction.getValue(Action.NAME)
puts "Paste action name is: #{name}"
# try really hard
action = TransferHandler.getCutAction
name = action.java_send(:getValue, [java.lang.String], Action.NAME)
puts "Cut action #{action.inspect} name is: #{name}"
# try another way; doesn't work because getValue takes an argument
#name = TransferHandler.getCutAction.value(Action.NAME)
#puts "Cut action name is: #{name}"
# try another way
meth = action.java_method(:getValue, [java.lang.String])
puts "Cut action name is: #{meth.call(Action.NAME)}"
puts "Cut action name is: #{meth.call(Action.NAME.to_java)}"
=== END deleteme.rb ===
$ jruby deleteme.rb
Cut action name is:
Copy action name is:
Paste action name is:
Cut action #<Java::JavaxSwing::TransferAction:0x7548c02f> name is:
Cut action name is:
Cut action name is:
$ jruby --version
jruby 1.7.4 (1.9.3p392) 2013-05-16 2390d3b on OpenJDK 64-Bit Server VM 1.6.0_22-b22 [linux-amd64]
C:\...> jruby deleteme.rb
[all names still nil]
C:\...> jruby --version
jruby 1.7.10 (1.9.3p392) 2014-01-09 c4ecd6b on Java HotSpot(TM) Client VM 1.6.0_37-b06 [Windows 7-x86]
---
Ryan Hinton
L-3 Communications / Communication Systems West
***@L-3com.com
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
Thanks!
=== deleteme.java ===
import java.io.*;
import javax.swing.*;
class Deleteme {
public static void main(String args[]) throws IOException {
String str;
str = (String)TransferHandler.getCutAction().getValue(Action.NAME);
System.out.println("Cut action name is: " + str);
str = (String)TransferHandler.getCopyAction().getValue(Action.NAME);
System.out.println("Copy action name is: " + str);
str = (String)TransferHandler.getPasteAction().getValue(Action.NAME);
System.out.println("Paste action name is: " + str);
}
}
=== END deleteme.java ===
$ javac deleteme.java
$ java Deleteme
Cut action name is: cut
Copy action name is: copy
Paste action name is: paste
=== deleteme.rb ===
require 'java'
# Easier way to do this at file scope? Normally I would just include_package
# 'javax.swing' in my class.
java_import javax.swing.TransferHandler
java_import javax.swing.Action
name = TransferHandler.getCutAction.getValue(Action.NAME)
puts "Cut action name is: #{name}"
name = TransferHandler.getCopyAction.getValue(Action.NAME)
puts "Copy action name is: #{name}"
name = TransferHandler.getPasteAction.getValue(Action.NAME)
puts "Paste action name is: #{name}"
# try really hard
action = TransferHandler.getCutAction
name = action.java_send(:getValue, [java.lang.String], Action.NAME)
puts "Cut action #{action.inspect} name is: #{name}"
# try another way; doesn't work because getValue takes an argument
#name = TransferHandler.getCutAction.value(Action.NAME)
#puts "Cut action name is: #{name}"
# try another way
meth = action.java_method(:getValue, [java.lang.String])
puts "Cut action name is: #{meth.call(Action.NAME)}"
puts "Cut action name is: #{meth.call(Action.NAME.to_java)}"
=== END deleteme.rb ===
$ jruby deleteme.rb
Cut action name is:
Copy action name is:
Paste action name is:
Cut action #<Java::JavaxSwing::TransferAction:0x7548c02f> name is:
Cut action name is:
Cut action name is:
$ jruby --version
jruby 1.7.4 (1.9.3p392) 2013-05-16 2390d3b on OpenJDK 64-Bit Server VM 1.6.0_22-b22 [linux-amd64]
C:\...> jruby deleteme.rb
[all names still nil]
C:\...> jruby --version
jruby 1.7.10 (1.9.3p392) 2014-01-09 c4ecd6b on Java HotSpot(TM) Client VM 1.6.0_37-b06 [Windows 7-x86]
---
Ryan Hinton
L-3 Communications / Communication Systems West
***@L-3com.com
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email