Moving a Tab in a JTabbedPane Container
import java.awt.Color;
import java.awt.Component;
import javax.swing.Icon;
import javax.swing.JTabbedPane;
public class Main {
public static void main(String[] argv) throws Exception {
JTabbedPane pane = new JTabbedPane();
int src = pane.getTabCount() - 1;
int dst = 0;
Component comp = pane.getComponentAt(src);
String label = pane.getTitleAt(src);
Icon icon = pane.getIconAt(src);
Icon iconDis = pane.getDisabledIconAt(src);
String tooltip = pane.getToolTipTextAt(src);
boolean enabled = pane.isEnabledAt(src);
int keycode = pane.getMnemonicAt(src);
int mnemonicLoc = pane.getDisplayedMnemonicIndexAt(src);
Color fg = pane.getForegroundAt(src);
Color bg = pane.getBackgroundAt(src);
pane.remove(src);
pane.insertTab(label, icon, comp, tooltip, dst);
pane.setDisabledIconAt(dst, iconDis);
pane.setEnabledAt(dst, enabled);
pane.setMnemonicAt(dst, keycode);
pane.setDisplayedMnemonicIndexAt(dst, mnemonicLoc);
pane.setForegroundAt(dst, fg);
pane.setBackgroundAt(dst, bg);
}
}
Related examples in the same category