I want to push/call the selected tab index value from the StateChanged method to another class or private method, How can I do this,
private class TabSelect implements ChangeListener {
@Override
public void stateChanged(ChangeEvent e) {
JTabbedPane source = (JTabbedPane) e.getSource();
if (source.getSelectedComponent() != null) {
source.getSelectedIndex();
}
}
}
I want to push this index value to the following method (or another public class in the same package). How to do this?
private JPanel CreateSlice() {
JPanel Slice = new JPanel();
Slice.setPreferredSize(new Dimension(550, 600));
Slice.add(button);
return Slice;
}
This is the CreateSlice's function,
private class TabPlus implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
JPanel panel = CreateSlice();
String title = "Slice " + String.valueOf(pane.getTabCount());
pane.insertTab(title, null, panel, null, pane.getTabCount() - 1);
}
}