Created
October 10, 2010 06:41
-
-
Save osima/619026 to your computer and use it in GitHub Desktop.
行番号表示付きでテキスト表示
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// g100pon #72 行番号表示付きでテキスト表示 | |
// | |
// Usage : groovy display file | |
import groovy.ui.* | |
import java.awt.* | |
import javax.swing.* | |
def ENC = 'UTF-8' | |
class MyConsoleTextEditor extends JPanel { | |
def edt | |
def MyConsoleTextEditor(){ | |
edt = new ConsoleTextEditor() | |
doMyLayout(); | |
} | |
private void doMyLayout(){ | |
setLayout(new BorderLayout()) | |
add( edt,BorderLayout.CENTER ) | |
} | |
void setText(String text){ | |
edt.textEditor.text = text | |
} | |
String getText(){ | |
edt.textEditor.text | |
} | |
} | |
if( args.length<1 ){ | |
println 'Usage: groovy display file' | |
System.exit(0) | |
} | |
editor = new MyConsoleTextEditor() | |
editor.text = new File(args[0]).getText(ENC) | |
frame = new JFrame() | |
frame.add( editor,BorderLayout.CENTER ) | |
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE) | |
frame.setSize(800,600) | |
frame.setVisible(true) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment