How can I make the button move from the first JTabbedPanel to the next one?
I created a a window panel that displays 6 tab panels, and I also made a
next and previous buttons to move from tab to tab. My problem is I was
only able to make it go from first one to last one. The buttons skip all
the other tabs and I can't seem to find a way to make it go through each
tab. This is what I did:
next = new JButton("Next");
next.addActionListener(
new ActionListener()
{
@Override
public void actionPerformed(ActionEvent event)
{
for(int i = 0; i <= tabs.getSelectedIndex(); i++)
tabs.setSelectedIndex(i);
}
});
previous = new JButton("Previous");
previous.addActionListener(
new ActionListener()
{
@Override
public void actionPerformed(ActionEvent event)
{
for(int i = 0; i >= tabs.getSelectedIndex(); i++)
tabs.setSelectedIndex(i);
}
});
I'm still going to try to figure this out.
No comments:
Post a Comment