Im basicly trying to add in a bunch of JPanels in each tab in the jtabbedpane, and it works fine on its own. But when following the Javatutorial on adding closingbuttons to each tab, it adds this weird tabContainer to the jtabbedpane after the first(and only the first) adding of a button. I realize Aqua is mac-related but problem still occurs linux and windows..
im basicly doing:
JTabbedPane pane;
this.add("channel",new JTextArea("texttexttext"));
ButtonTabComponent ctb = new ButtonTabComponent(pane);
this.setTabComponentAt(pane.indexOfTab("channel"),ctb);
the first tab also works perfectly, but all the next ones added is beeing pushed one index over because of the AquaTabbedPaneCopyFromBasicUI$TabContainer, as one can see in the screenshot. So when im trying to get them out of the tabbedpane to update some info(check the code linked below) i cant cast it, because the index beeing returned from indexOfTab(Channel), is the index of the aqua..
screenShot of debugging and the array of jtabbedPane: http://server.westman.no/free/Skjermbilde%202011-11-18%20kl.%2012.32.02.png
whats worse is that i cant remove index 2 in the tabbedpane, i just get outOfBoundsException, but i can use getComponent(2),(and thats where i first found the bug, because i can getComponent(title) and it tries to return the Aqua... and then i cant cast it to a singletab object which is what want)
This is a surreal problem which probably looks like some youHaveToHaveDoneSomethingElseWrong, but ive been at this for a week, and after having sevral people looking at it, im no closer to a solution. (It can ofcourse be a gotDamnUrADumbAss problem tough..)
Hope this made sense to someone!
Code in question : tabHandler : http://apps.netcrawlr.net/p/pastebin.php?show=41
comment if you would like to see something else referenced.
sscce:
package jtabbedtest;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
/**
*
* @author hallvardwestman
*/
public class Jtabbedtest {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
JFrame jf = new JFrame();
JTabbedPane jt = new JTabbedPane();
//debugChecks for whats in jtabbedpane
Object[] o = jt.getComponents();
jf.add(jt);
jt.addTab("a",new JTextArea("a"));
int tabIndex = jt.indexOfTab("a");
ButtonTabComponent ctb = new ButtonTabComponent(jt);
jt.setTabComponentAt(tabIndex, ctb);
/*
* adding closebutton
*/
//debugChecks for whats in jtabbedpane
o = jt.getComponents();
jf.setVisible(true);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
and just put this : http://docs.oracle.com/javase/tutorial/displayCode.html?code=http://docs.oracle.com/javase/tutorial/uiswing/examples/components/TabComponentsDemoProject/src/components/ButtonTabComponent.java in a new file called ButtonTabComponent