Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
重複の可能性: Java の Java タブ付きペインにボタン コンポーネントを追加する
JTabbedPane タブ (タブ自体) にボタンを追加して、クリックするとタブを閉じるなどのアクションを実行できるようにすることはできますか?
もちろん。まず、次のようにタブを追加します。
JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.add( "title", content );
次に、「タイトル」ラベルを次のように変更します。
tabbedPane.setTabComponentAt( 0, new JButton( "This is now a button!" ) ); // 0 is the tabindex