I´ve got a JTabbedPane with JTextArea. An methode creates another tab an adds it to the JTabbedPane. Now I want to implement, that the new created tab gets another color untill it is opened the first time, like in a Chatroom to show that theres a new message from a specific user. I don´t really know how do implement this. I thried to use a while-loop, but it didn´t work
String name = "...";
JTabbedPane tabs = new JTabbedPane();
JTextArea textarea = new JTextArea();
textarea.setEditable(false);
textarea.setLineWrap(true);
JScrollPane jScrollPane = new JScrollPane(textarea);
jScrollPane.setPreferredSize(new Dimension(300, 300));
tabs.add(name, jScrollPane);
tabs.setBackgroundAt(tabs.indexOfTab(name),Color.GREEN);
while(true){
if(tabs.getSelectedIndex() == tabs.indexOfTab(name)){
tabs.setBackgroundAt(tabs.indexOfTab(name),Color.GRAY);
break;
}
}