by rathinamsm » Mon Apr 02, 2012 12:51 am
Hi Team,
I tried to set the background and foreground to jidetabbedpane as you specified by the setForegroundat(), and setBackgroundat(). in the following ways.
1.Setting the TabbedPane Customizer addChangeListener();
arg0.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent changeEvent) {
int index = arg0.getSelectedIndex();
int tabCount = arg0.getTabCount();
try {
for (int i = 0; i < tabCount; i++) {
if (i == index) {
arg0.setForegroundAt(i,Color.BLUE);
arg0.setBackgroundAt(i,Color.GREEN);
} else {
arg0.setForegroundAt(i,Color.BLUE);
arg0.setBackgroundAt(i,Color.RED);
}
}
} catch (Exception e2) {
}
}
});
2. Defining Color at Override paintBackground() Method in BasicJidetabbedpane(); which SetUi to Frame Container. as like follows.
@Override
public void paintBackground(Graphics arg0, Component arg1) {
JideTabbedPane jideTabbedPane = (JideTabbedPane)arg1;
jideTabbedPane.setOpaque(false);
try {
int index = jideTabbedPane.getSelectedIndex();
for (int i = 0; i < jideTabbedPane.getTabCount(); i++) {
if (i == index) {
jideTabbedPane.setForegroundAt(i,Color.WHITE);
jideTabbedPane.setBackgroundAt(i,Color.GREEN);
} else {
jideTabbedPane.setForegroundAt(i,Color.WHITE);
jideTabbedPane.setBackgroundAt(i,Color.RED);
}
}
} catch (Exception e2) {
e2.printStackTrace();
}
super.paintBackground(arg0, arg1);
}
3. Making the ChangeSkin Method, as Like Follows,
protected void changeSkin() {
resetSkin();
jideTabbedPane.revalidate();
jideTabbedPane.repaint();
validate();
repaint();
}
private void resetSkin() {
int index = jideTabbedPane.getSelectedIndex();
int tabCount = jideTabbedPane.getTabCount();
try {
for (int i = 0; i < tabCount; i++) {
if (i == index) {
jideTabbedPane.setForegroundAt(i,Color.ORANGE);
jideTabbedPane.setBackgroundAt(i,Color.GREEN);
} else {
jideTabbedPane.setForegroundAt(i,Color.ORANGE);
jideTabbedPane.setBackgroundAt(i,Color.RED);
}
jideTabbedPane.revalidate();
jideTabbedPane.repaint();
}
} catch (Exception e2) {
}
}
Please see the Screen Shot_01, in that the setBackgroundAt(), color is not repainted.
Only the foreground is repainting in resetskin().
How can i able to resolve this problem?
Is Any way to set Background for tab?
- Attachments
-
FrameContainer_test.java
- Contains Two Class please separate these as two class.
- (3.44 KiB) Downloaded 2954 times
-
InitialLayoutDockDemo.java
- (7.92 KiB) Downloaded 2940 times
-

- Screen Shot_01.PNG (9.23 KiB) Viewed 87916 times