Skip to content

Instantly share code, notes, and snippets.

@osima
Created October 10, 2010 06:41
Show Gist options
  • Save osima/619026 to your computer and use it in GitHub Desktop.
Save osima/619026 to your computer and use it in GitHub Desktop.
行番号表示付きでテキスト表示
// 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