Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
require 'java' import 'javax.swing.JFrame' import 'javax.swing.JLabel' import 'javax.swing.SwingUtilities' import 'java.lang.Runnable' class SwingDemo def initialize jfrm = JFrame.new "A Simple Demo" jfrm.setSize(275,100) jfrm.default_close_operation = JFrame::EXIT_ON_CLOSE jlab = JLabel.new " Swing powers the modern Java GUI" jfrm.add jlab jfrm.pack jfrm.visible = true end end class RunnableProc include Runnable def initialize(&block) @block = block end def run @block.call end end class Proc def to_runnable RunnableProc.new &self end end SwingUtilities.invoke_later(proc { SwingDemo.new }.to_runnable)
From the Design Piracy series on my blog: