Sha256: f4eba5cc7c993b1541e41a668b069532e6048dc7ca9b30fee8fb9537cdd987a0

Contents?: true

Size: 956 Bytes

Versions: 5

Compression:

Stored size: 956 Bytes

Contents

include Java

require 'rubygems'
require 'rubeus'

Rubeus::Swing.irb

import 'java.io.FileInputStream'
import 'java.io.FileOutputStream'

rtf_editor_kit = RTFEditorKit.new

JFrame.new('Notepad') do |frame|
	JScrollPane.new do |pane|
		pane.vertical_scroll_bar_policy = ScrollPaneConstants::VERTICAL_SCROLLBAR_AS_NEEDED
		pane.horizontal_scroll_bar_policy = ScrollPaneConstants::HORIZONTAL_SCROLLBAR_NEVER
		@text_pane = JTextPane.new
		@text_pane.document = DefaultStyledDocument.new StyleContext.new
	end

  file_path = File.join(File.dirname(__FILE__), 'notepad.rtf')
	rtf_editor_kit.read FileInputStream.new(file_path), @text_pane.document, 0
	
	@text_pane.listen(:key, :key_released) do |event|
		rtf_editor_kit.write FileOutputStream.new(file_path), @text_pane.document, 0, @text_pane.document.length
	end

	frame.default_close_operation = JFrame::EXIT_ON_CLOSE
	frame.set_size(300, 200)
	frame.set_location_relative_to(nil)
	frame.visible = true
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubeus-0.0.8-java examples/notepad.rb
rubeus-0.0.4-java examples/notepad.rb
rubeus-0.0.7-java examples/notepad.rb
rubeus-0.0.5-java examples/notepad.rb
rubeus-0.0.6-java examples/notepad.rb