1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

jsonを取得、表示するアプリケーション その3

Posted at

HTTPメソッドを指定するコンボボックスを追加してPOSTメソッドに対応する
あと、設定していなかったタイトルを設定

json_client.groovy
import groovy.swing.SwingBuilder
import javax.swing.*
import java.awt.*

def cbMethod
def txtUrl
def txtJson

def sendRequest = {
	def conn = txtUrl.text.toURL().openConnection()
	conn.requestMethod = cbMethod.selectedItem
	
	txtJson.text = conn.inputStream.text
}

new SwingBuilder().frame(title:'jsonを取得、表示するアプリケーション', defaultCloseOperation:JFrame.EXIT_ON_CLOSE,
						size: [800, 600], show:true) {
	lookAndFeel('nimbus')
	borderLayout()
	hbox(constraints: BorderLayout.NORTH) {
		cbMethod = comboBox(items:['GET', 'POST'])
		txtUrl = textField()
		button(text:'送信', actionPerformed:sendRequest)
	}
	scrollPane(constraints: BorderLayout.CENTER) {
		txtJson = textArea(editable:false)
	}
}

qiita-003.png

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?