Help us understand the problem. What is going on with this article?

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

More than 5 years have passed since last update.

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

hina0118
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away