{"id":83550,"date":"2024-03-21T03:01:32","date_gmt":"2024-03-20T18:01:32","guid":{"rendered":"https:\/\/www.silicloud.com\/ja\/blog\/swing%e3%82%b3%e3%83%b3%e3%83%9c%e3%83%9c%e3%83%83%e3%82%af%e3%82%b9\/"},"modified":"2024-03-28T08:24:16","modified_gmt":"2024-03-27T23:24:16","slug":"swing%e3%82%b3%e3%83%b3%e3%83%9c%e3%83%9c%e3%83%83%e3%82%af%e3%82%b9","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/ja\/blog\/swing%e3%82%b3%e3%83%b3%e3%83%9c%e3%83%9c%e3%83%83%e3%82%af%e3%82%b9\/","title":{"rendered":"swing\u30b3\u30f3\u30dc\u30dc\u30c3\u30af\u30b9"},"content":{"rendered":"<p>Swing\u306b\u304a\u3051\u308b\u30b3\u30f3\u30dc\u30dc\u30c3\u30af\u30b9\u306fJComboBox\u30af\u30e9\u30b9\u3067\u5b9f\u88c5\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u4ee5\u4e0b\u306b\u30b3\u30f3\u30dc\u30dc\u30c3\u30af\u30b9\u3092\u4f5c\u6210\u3057\u3066\u4f7f\u7528\u3059\u308b\u7c21\u5358\u306a\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"hljs-keyword\">import<\/span> javax.swing.*;\r\n<span class=\"hljs-keyword\">import<\/span> java.awt.event.ActionEvent;\r\n<span class=\"hljs-keyword\">import<\/span> java.awt.event.ActionListener;\r\n\r\n<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title class_\">ComboBoxExample<\/span> <span class=\"hljs-keyword\">extends<\/span> <span class=\"hljs-title class_\">JFrame<\/span> {\r\n    <span class=\"hljs-keyword\">private<\/span> JComboBox&lt;String&gt; comboBox;\r\n    <span class=\"hljs-keyword\">private<\/span> JLabel label;\r\n\r\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-title function_\">ComboBoxExample<\/span><span class=\"hljs-params\">()<\/span> {\r\n        <span class=\"hljs-comment\">\/\/ \u521b\u5efa\u4e00\u4e2aJFrame\u7a97\u53e3<\/span>\r\n        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\r\n        setSize(<span class=\"hljs-number\">300<\/span>, <span class=\"hljs-number\">200<\/span>);\r\n\r\n        <span class=\"hljs-comment\">\/\/ \u521b\u5efa\u4e00\u4e2aJPanel\u9762\u677f<\/span>\r\n        <span class=\"hljs-type\">JPanel<\/span> <span class=\"hljs-variable\">panel<\/span> <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">JPanel<\/span>();\r\n\r\n        <span class=\"hljs-comment\">\/\/ \u521b\u5efa\u4e00\u4e2aJComboBox\u7ec4\u5408\u6846<\/span>\r\n        String[] options = {<span class=\"hljs-string\">\"\u9009\u98791\"<\/span>, <span class=\"hljs-string\">\"\u9009\u98792\"<\/span>, <span class=\"hljs-string\">\"\u9009\u98793\"<\/span>};\r\n        comboBox = <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">JComboBox<\/span>&lt;String&gt;(options);\r\n\r\n        <span class=\"hljs-comment\">\/\/ \u6dfb\u52a0\u4e00\u4e2a\u4e8b\u4ef6\u76d1\u542c\u5668\uff0c\u5f53\u9009\u62e9\u9879\u53d1\u751f\u53d8\u5316\u65f6\u89e6\u53d1<\/span>\r\n        comboBox.addActionListener(<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">ActionListener<\/span>() {\r\n            <span class=\"hljs-meta\">@Override<\/span>\r\n            <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title function_\">actionPerformed<\/span><span class=\"hljs-params\">(ActionEvent e)<\/span> {\r\n                <span class=\"hljs-comment\">\/\/ \u83b7\u53d6\u9009\u62e9\u7684\u9879<\/span>\r\n                <span class=\"hljs-type\">String<\/span> <span class=\"hljs-variable\">selectedOption<\/span> <span class=\"hljs-operator\">=<\/span> (String) comboBox.getSelectedItem();\r\n                <span class=\"hljs-comment\">\/\/ \u66f4\u65b0\u6807\u7b7e\u7684\u6587\u672c<\/span>\r\n                label.setText(<span class=\"hljs-string\">\"\u4f60\u9009\u62e9\u4e86\uff1a\"<\/span> + selectedOption);\r\n            }\r\n        });\r\n\r\n        <span class=\"hljs-comment\">\/\/ \u521b\u5efa\u4e00\u4e2aJLabel\u6807\u7b7e<\/span>\r\n        label = <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">JLabel<\/span>(<span class=\"hljs-string\">\"\u8bf7\u9009\u62e9\u4e00\u4e2a\u9009\u9879\"<\/span>);\r\n\r\n        <span class=\"hljs-comment\">\/\/ \u5c06\u7ec4\u4ef6\u6dfb\u52a0\u5230\u9762\u677f<\/span>\r\n        panel.add(comboBox);\r\n        panel.add(label);\r\n\r\n        <span class=\"hljs-comment\">\/\/ \u5c06\u9762\u677f\u6dfb\u52a0\u5230\u7a97\u53e3<\/span>\r\n        add(panel);\r\n    }\r\n\r\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">static<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title function_\">main<\/span><span class=\"hljs-params\">(String[] args)<\/span> {\r\n        <span class=\"hljs-comment\">\/\/ \u521b\u5efa\u5e76\u663e\u793a\u7a97\u53e3<\/span>\r\n        <span class=\"hljs-type\">ComboBoxExample<\/span> <span class=\"hljs-variable\">frame<\/span> <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">ComboBoxExample<\/span>();\r\n        frame.setVisible(<span class=\"hljs-literal\">true<\/span>);\r\n    }\r\n}\r\n<\/code><\/pre>\n<p>\u3053\u306e\u30b5\u30f3\u30d7\u30eb\u3067\u306f\u3001\u30b3\u30f3\u30dc \u30dc\u30c3\u30af\u30b9\u3068\u30e9\u30d9\u30eb\u3092\u542b\u3080\u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u3044\u305a\u308c\u304b\u306e\u9078\u629e\u30a2\u30a4\u30c6\u30e0\u304c\u5909\u66f4\u3055\u308c\u308b\u3068\u3001\u30e9\u30d9\u30eb\u306e\u30c6\u30ad\u30b9\u30c8\u306f\u66f4\u65b0\u3055\u308c\u307e\u3059\u3002\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u3001\u3053\u306e\u30b5\u30f3\u30d7\u30eb\u3092\u4fee\u6b63\u3057\u3066\u62e1\u5f35\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Swing\u306b\u304a\u3051\u308b\u30b3\u30f3\u30dc\u30dc\u30c3\u30af\u30b9\u306fJComboBox\u30af\u30e9\u30b9\u3067\u5b9f\u88c5\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u4ee5\u4e0b\u306b\u30b3\u30f3\u30dc\u30dc\u30c3\u30af\u30b9\u3092\u4f5c\u6210\u3057\u3066\u4f7f\u7528\u3059\u308b\u7c21\u5358\u306a\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002 import javax.swing.*; import java.awt.eve [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-83550","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>swing\u30b3\u30f3\u30dc\u30dc\u30c3\u30af\u30b9 - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/ja\/blog\/swing\u30b3\u30f3\u30dc\u30dc\u30c3\u30af\u30b9\/\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"swing\u30b3\u30f3\u30dc\u30dc\u30c3\u30af\u30b9\" \/>\n<meta property=\"og:description\" content=\"Swing\u306b\u304a\u3051\u308b\u30b3\u30f3\u30dc\u30dc\u30c3\u30af\u30b9\u306fJComboBox\u30af\u30e9\u30b9\u3067\u5b9f\u88c5\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u4ee5\u4e0b\u306b\u30b3\u30f3\u30dc\u30dc\u30c3\u30af\u30b9\u3092\u4f5c\u6210\u3057\u3066\u4f7f\u7528\u3059\u308b\u7c21\u5358\u306a\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002 import javax.swing.*; import java.awt.eve [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/ja\/blog\/swing\u30b3\u30f3\u30dc\u30dc\u30c3\u30af\u30b9\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-20T18:01:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-27T23:24:16+00:00\" \/>\n<meta name=\"author\" content=\"\u590f\u6a39, \u98a8\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u57f7\u7b46\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u590f\u6a39, \u98a8\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/swing%e3%82%b3%e3%83%b3%e3%83%9c%e3%83%9c%e3%83%83%e3%82%af%e3%82%b9\/\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/swing%e3%82%b3%e3%83%b3%e3%83%9c%e3%83%9c%e3%83%83%e3%82%af%e3%82%b9\/\",\"name\":\"swing\u30b3\u30f3\u30dc\u30dc\u30c3\u30af\u30b9 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\"},\"datePublished\":\"2024-03-20T18:01:32+00:00\",\"dateModified\":\"2024-03-27T23:24:16+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/4e591db2661c4cc425470b461259391d\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/swing%e3%82%b3%e3%83%b3%e3%83%9c%e3%83%9c%e3%83%83%e3%82%af%e3%82%b9\/#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/ja\/blog\/swing%e3%82%b3%e3%83%b3%e3%83%9c%e3%83%9c%e3%83%83%e3%82%af%e3%82%b9\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/swing%e3%82%b3%e3%83%b3%e3%83%9c%e3%83%9c%e3%83%83%e3%82%af%e3%82%b9\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/ja\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"swing\u30b3\u30f3\u30dc\u30dc\u30c3\u30af\u30b9\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"ja\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/4e591db2661c4cc425470b461259391d\",\"name\":\"\u590f\u6a39, \u98a8\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/65e0ff40534461b1fa000382dc194e1716f793ab0bcb218ac3c40895551a08c5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/65e0ff40534461b1fa000382dc194e1716f793ab0bcb218ac3c40895551a08c5?s=96&d=mm&r=g\",\"caption\":\"\u590f\u6a39, \u98a8\"},\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/author\/natsukikaze\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/swing%e3%82%b3%e3%83%b3%e3%83%9c%e3%83%9c%e3%83%83%e3%82%af%e3%82%b9\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"swing\u30b3\u30f3\u30dc\u30dc\u30c3\u30af\u30b9 - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/ja\/blog\/swing\u30b3\u30f3\u30dc\u30dc\u30c3\u30af\u30b9\/","og_locale":"ja_JP","og_type":"article","og_title":"swing\u30b3\u30f3\u30dc\u30dc\u30c3\u30af\u30b9","og_description":"Swing\u306b\u304a\u3051\u308b\u30b3\u30f3\u30dc\u30dc\u30c3\u30af\u30b9\u306fJComboBox\u30af\u30e9\u30b9\u3067\u5b9f\u88c5\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u4ee5\u4e0b\u306b\u30b3\u30f3\u30dc\u30dc\u30c3\u30af\u30b9\u3092\u4f5c\u6210\u3057\u3066\u4f7f\u7528\u3059\u308b\u7c21\u5358\u306a\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002 import javax.swing.*; import java.awt.eve [&hellip;]","og_url":"https:\/\/www.silicloud.com\/ja\/blog\/swing\u30b3\u30f3\u30dc\u30dc\u30c3\u30af\u30b9\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2024-03-20T18:01:32+00:00","article_modified_time":"2024-03-27T23:24:16+00:00","author":"\u590f\u6a39, \u98a8","twitter_card":"summary_large_image","twitter_misc":{"\u57f7\u7b46\u8005":"\u590f\u6a39, \u98a8"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/ja\/blog\/swing%e3%82%b3%e3%83%b3%e3%83%9c%e3%83%9c%e3%83%83%e3%82%af%e3%82%b9\/","url":"https:\/\/www.silicloud.com\/ja\/blog\/swing%e3%82%b3%e3%83%b3%e3%83%9c%e3%83%9c%e3%83%83%e3%82%af%e3%82%b9\/","name":"swing\u30b3\u30f3\u30dc\u30dc\u30c3\u30af\u30b9 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website"},"datePublished":"2024-03-20T18:01:32+00:00","dateModified":"2024-03-27T23:24:16+00:00","author":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/4e591db2661c4cc425470b461259391d"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/swing%e3%82%b3%e3%83%b3%e3%83%9c%e3%83%9c%e3%83%83%e3%82%af%e3%82%b9\/#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/ja\/blog\/swing%e3%82%b3%e3%83%b3%e3%83%9c%e3%83%9c%e3%83%83%e3%82%af%e3%82%b9\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/ja\/blog\/swing%e3%82%b3%e3%83%b3%e3%83%9c%e3%83%9c%e3%83%83%e3%82%af%e3%82%b9\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/ja\/blog\/"},{"@type":"ListItem","position":2,"name":"swing\u30b3\u30f3\u30dc\u30dc\u30c3\u30af\u30b9"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website","url":"https:\/\/www.silicloud.com\/ja\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"ja"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/4e591db2661c4cc425470b461259391d","name":"\u590f\u6a39, \u98a8","image":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/65e0ff40534461b1fa000382dc194e1716f793ab0bcb218ac3c40895551a08c5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/65e0ff40534461b1fa000382dc194e1716f793ab0bcb218ac3c40895551a08c5?s=96&d=mm&r=g","caption":"\u590f\u6a39, \u98a8"},"url":"https:\/\/www.silicloud.com\/ja\/blog\/author\/natsukikaze\/"},{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/swing%e3%82%b3%e3%83%b3%e3%83%9c%e3%83%9c%e3%83%83%e3%82%af%e3%82%b9\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/83550","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/comments?post=83550"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/83550\/revisions"}],"predecessor-version":[{"id":202615,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/83550\/revisions\/202615"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/media?parent=83550"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/categories?post=83550"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/tags?post=83550"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}