{"id":64840,"date":"2025-05-03T17:16:50","date_gmt":"2025-05-03T09:16:50","guid":{"rendered":"https:\/\/fwq.ai\/blog\/64840\/"},"modified":"2025-05-03T17:16:50","modified_gmt":"2025-05-03T09:16:50","slug":"jtabbedpane-%e7%9a%84-add-%e5%92%8c-addtab-%e6%96%b9%e6%b3%95%e6%9c%89%e4%bd%95%e5%8c%ba%e5%88%ab%ef%bc%9f-3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/64840\/","title":{"rendered":"JTabbedPane \u7684 add() \u548c addTab() \u65b9\u6cd5\u6709\u4f55\u533a\u522b\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173080370441727.jpg\" class=\"aligncenter\" title=\"JTabbedPane \u7684 add() \u548c addTab() \u65b9\u6cd5\u6709\u4f55\u533a\u522b\uff1f\u63d2\u56fe\" alt=\"JTabbedPane \u7684 add() \u548c addTab() \u65b9\u6cd5\u6709\u4f55\u533a\u522b\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>jtabbedpane \u7c7b\u4e2d\u7684 add() \u548c addtab() \u65b9\u6cd5<\/strong><\/p>\n<p>jtabbedpane \u7c7b\u63d0\u4f9b\u4e24\u4e2a\u65b9\u6cd5\u6765\u5411\u9009\u9879\u5361\u7a97\u683c\u4e2d\u6dfb\u52a0\u7ec4\u4ef6\uff1aadd() \u548c addtab()\u3002\u8fd9\u4e24\u4e2a\u65b9\u6cd5\u4e4d\u4e00\u770b\u4f3c\u4e4e\u529f\u80fd\u76f8\u540c\uff0c\u4f46\u5728\u5173\u952e\u65b9\u9762\u6709\u6240\u4e0d\u540c\u3002<\/p>\n<p><strong>\u8fd4\u56de\u503c<\/strong><\/p>\n<p>add() \u65b9\u6cd5\u8fd4\u56de void\uff0c\u56e0\u4e3a\u5b83\u4fee\u6539\u4e86\u9009\u9879\u5361\u7a97\u683c\u7684\u7ed3\u6784\u800c\u4e0d\u8fd4\u56de\u4efb\u4f55\u503c\u3002\u53e6\u4e00\u65b9\u9762\uff0caddtab() \u65b9\u6cd5\u8fd4\u56de\u4e00\u4e2a int\uff0c\u8868\u793a\u65b0\u6dfb\u52a0\u7684\u9009\u9879\u5361\u7684\u7d22\u5f15\u3002\u7d22\u5f15\u5bf9\u4e8e\u83b7\u53d6\u6216\u5220\u9664\u9009\u9879\u5361\u6216\u8bbf\u95ee\u5176\u7ec4\u4ef6\u5f88\u6709\u7528\u3002<\/p>\n<p><strong>\u4f7f\u7528\u793a\u4f8b<\/strong><\/p>\n<p>\u4ee5\u4e0b\u662f\u8fd9\u4e24\u4e2a\u65b9\u6cd5\u7684\u7528\u6cd5\u793a\u4f8b\uff1a<\/p>\n<pre>\/\/ \u4f7f\u7528 add() \u65b9\u6cd5\nJTabbedPane tabbedPane = new JTabbedPane();\ntabbedPane.add(\"\u9009\u9879\u5361 1\", new JPanel());\n\n\/\/ \u4f7f\u7528 addTab() \u65b9\u6cd5\nint index = tabbedPane.addTab(\"\u9009\u9879\u5361 2\", new JPanel());<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u793a\u4f8b\u4e2d\uff1a<\/p>\n<ul>\n<li>add() \u65b9\u6cd5\u5c06\u4e00\u4e2a\u6ca1\u6709\u6807\u9898\u7684\u9762\u677f\u6dfb\u52a0\u5230\u9009\u9879\u5361\u7a97\u683c\u4e2d\u3002<\/li>\n<li>addtab() \u65b9\u6cd5\u5c06\u5e26\u6807\u9898\u7684\u9762\u677f\u6dfb\u52a0\u5230\u9009\u9879\u5361\u7a97\u683c\u4e2d\u5e76\u8fd4\u56de\u65b0\u9009\u9879\u5361\u7684\u7d22\u5f15\u3002<\/li>\n<\/ul>\n<p>\u56e0\u6b64\uff0c\u5728\u9700\u8981\u83b7\u53d6\u65b0\u6dfb\u52a0\u9009\u9879\u5361\u7684\u7d22\u5f15\u65f6\uff0c\u4f7f\u7528 addtab() \u65b9\u6cd5\u66f4\u52a0\u65b9\u4fbf\u3002\u5426\u5219\uff0c\u53ef\u4ee5\u4f7f\u7528 add() \u65b9\u6cd5\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fJTabbedPane \u7684 add() \u548c addTab() \u65b9\u6cd5\u6709\u4f55\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8IDCBABY\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>jtabbedpane \u7c7b\u4e2d\u7684 add() \u548c addtab() \u65b9\u6cd5 jtabbedpane \u7c7b\u63d0\u4f9b\u4e24\u4e2a\u65b9\u6cd5\u6765\u5411\u9009\u9879\u5361\u7a97\u683c\u4e2d\u6dfb\u52a0\u7ec4\u4ef6\uff1aadd() \u548c addtab()\u3002\u8fd9\u4e24\u4e2a\u65b9\u6cd5\u4e4d\u4e00\u770b\u4f3c\u4e4e\u529f\u80fd\u76f8\u540c\uff0c\u4f46\u5728\u5173\u952e\u65b9\u9762\u6709\u6240\u4e0d\u540c\u3002 \u8fd4\u56de\u503c add() \u65b9\u6cd5\u8fd4\u56de void\uff0c\u56e0\u4e3a\u5b83\u4fee\u6539\u4e86\u9009\u9879\u5361\u7a97\u683c\u7684\u7ed3\u6784\u800c\u4e0d\u8fd4\u56de\u4efb\u4f55\u503c\u3002\u53e6\u4e00\u65b9\u9762\uff0caddtab() \u65b9\u6cd5\u8fd4\u56de\u4e00\u4e2a int\uff0c\u8868\u793a\u65b0\u6dfb\u52a0\u7684\u9009\u9879\u5361\u7684\u7d22\u5f15\u3002\u7d22\u5f15\u5bf9\u4e8e\u83b7\u53d6\u6216\u5220\u9664\u9009\u9879\u5361\u6216\u8bbf\u95ee\u5176\u7ec4\u4ef6\u5f88\u6709\u7528\u3002 \u4f7f\u7528\u793a\u4f8b \u4ee5\u4e0b\u662f\u8fd9\u4e24\u4e2a\u65b9\u6cd5\u7684\u7528\u6cd5\u793a\u4f8b\uff1a \/\/ \u4f7f\u7528 add() \u65b9\u6cd5 JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.add(&#8220;\u9009\u9879\u5361 1&#8221;, new JPanel()); \/\/ \u4f7f\u7528 addTab() \u65b9\u6cd5 int index = tabbedPane.addTab(&#8220;\u9009\u9879\u5361 2&#8221;, new JPanel()); \u767b\u5f55\u540e\u590d\u5236 \u5728\u793a\u4f8b\u4e2d\uff1a add() \u65b9\u6cd5\u5c06\u4e00\u4e2a\u6ca1\u6709\u6807\u9898\u7684\u9762\u677f\u6dfb\u52a0\u5230\u9009\u9879\u5361\u7a97\u683c\u4e2d\u3002 addtab() \u65b9\u6cd5\u5c06\u5e26\u6807\u9898\u7684\u9762\u677f\u6dfb\u52a0\u5230\u9009\u9879\u5361\u7a97\u683c\u4e2d\u5e76\u8fd4\u56de\u65b0\u9009\u9879\u5361\u7684\u7d22\u5f15\u3002 \u56e0\u6b64\uff0c\u5728\u9700\u8981\u83b7\u53d6\u65b0\u6dfb\u52a0\u9009\u9879\u5361\u7684\u7d22\u5f15\u65f6\uff0c\u4f7f\u7528 addtab() \u65b9\u6cd5\u66f4\u52a0\u65b9\u4fbf\u3002\u5426\u5219\uff0c\u53ef\u4ee5\u4f7f\u7528 add() \u65b9\u6cd5\u3002 \u4ee5\u4e0a\u5c31\u662fJTabbedPane \u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-64840","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/64840","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=64840"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/64840\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=64840"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=64840"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=64840"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}