6 つのタブ パネルを表示するウィンドウ パネルを作成し、タブからタブに移動するための次と前のボタンも作成しました。私の問題は、最初のタブから最後のタブにしか移動できなかったことです。ボタンは他のすべてのタブをスキップし、各タブを通過させる方法が見つからないようです。これは私がしたことです:
next = new JButton("next");
next.addActionListener(
new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
for(int i = 0; i <= tabs.getSelectedIndex(); i++)
tabs.setSelectedIndex(i);
}
});
previous = new JButton("previous");
previous.addActionListener(
new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
for(int i = 0; i >= tabs.getSelectedIndex(); i++)
tabs.setSelectedIndex(i);
}
});
私はまだこれを理解しようとするつもりです。