sdeboy 2003/07/21 20:07:47
Modified: src/java/org/apache/log4j/chainsaw LogUI.java
ChainsawTabbedPane.java
Log:
Added checks to ensure we didn't try to set an icon on a tab that isn't docked or
isn't being displayed.
Also updated code that re-selects the last previously selected tab when new tabs
were added to prevent an outofbounds condition
PR:
Obtained from:
Submitted by:
Reviewed by:
CVS: ----------------------------------------------------------------------
CVS: PR:
CVS: If this change addresses a PR in the problem report tracking
CVS: database, then enter the PR number(s) here.
CVS: Obtained from:
CVS: If this change has been taken from another system, such as NCSA,
CVS: then name the system in this line, otherwise delete it.
CVS: Submitted by:
CVS: If this code has been contributed to Apache by someone else; i.e.,
CVS: they sent us a patch or a new module, then include their name/email
CVS: address here. If this is your work then delete this line.
CVS: Reviewed by:
CVS: If we are doing pre-commit code reviews and someone else has
CVS: reviewed your changes, include their name(s) here.
CVS: If you have not had it reviewed then delete this line.
Revision Changes Path
1.6 +5 -3 jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogUI.java
Index: LogUI.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogUI.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- LogUI.java 20 Jul 2003 15:41:48 -0000 1.5
+++ LogUI.java 22 Jul 2003 03:07:47 -0000 1.6
@@ -456,7 +456,9 @@
//received a statechange event - selection changed - remove icon from
selected index
public void stateChanged(ChangeEvent e) {
if (tabbedPane.getSelectedComponent() instanceof ChainsawTabbedPane) {
- tabbedPane.setIconAt(tabbedPane.getSelectedIndex(), null);
+ if (tabbedPane.getSelectedIndex() > -1) {
+ tabbedPane.setIconAt(tabbedPane.getSelectedIndex(), null);
+ }
}
}
});
@@ -2331,8 +2333,8 @@
public void run() {
while (true) {
//if this tab is active, remove the icon
- if (
- tabbedPane.getSelectedIndex() == tabbedPane.indexOfTab(ident)) {
+ if ((tabbedPane.getSelectedIndex() > -1) &&
+ (tabbedPane.getSelectedIndex() == tabbedPane.indexOfTab(ident))) {
tabbedPane.setIconAt(tabbedPane.indexOfTab(ident), null);
//reset fields so no icon will display
1.2 +2 -2
jakarta-log4j/src/java/org/apache/log4j/chainsaw/ChainsawTabbedPane.java
Index: ChainsawTabbedPane.java
===================================================================
RCS file:
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/ChainsawTabbedPane.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ChainsawTabbedPane.java 25 Jun 2003 04:05:22 -0000 1.1
+++ ChainsawTabbedPane.java 22 Jul 2003 03:07:47 -0000 1.2
@@ -117,8 +117,8 @@
public void addANewTab(String name, JComponent component, Icon icon) {
int selectedIndex = getSelectedIndex();
super.insertTab(name, icon, component, null, 0);
-
- if (getTabCount() >= (selectedIndex + 1)) {
+ //only select the previously existing tab if there is more than one tab
+ if (getTabCount() > 1) {
setSelectedIndex(selectedIndex + 1);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]