You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by sd...@apache.org on 2004/04/09 09:54:17 UTC
cvs commit: logging-log4j/src/java/org/apache/log4j/chainsaw ChainsawTabbedPane.java
sdeboy 2004/04/09 00:54:17
Modified: src/java/org/apache/log4j/chainsaw ChainsawTabbedPane.java
Log:
Attempting to set tab layout policy using reflection to 'scroll_tab_layout' (method available as of 1.4 - reflection used in order to maintain compatibility with 1.3 VMs)
Removed unused constructor
Revision Changes Path
1.5 +23 -11 logging-log4j/src/java/org/apache/log4j/chainsaw/ChainsawTabbedPane.java
Index: ChainsawTabbedPane.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/chainsaw/ChainsawTabbedPane.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ChainsawTabbedPane.java 27 Feb 2004 16:47:29 -0000 1.4
+++ ChainsawTabbedPane.java 9 Apr 2004 07:54:17 -0000 1.5
@@ -1,12 +1,12 @@
/*
* Copyright 1999,2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,6 +22,8 @@
import java.awt.Component;
+import java.lang.reflect.Method;
+
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JTabbedPane;
@@ -47,17 +49,26 @@
class ChainsawTabbedPane extends JTabbedPane {
/**
*
+ * Create the tabbed pane.
+ *
+ * Attempts to call via reflection the
+ * 'setTabLayoutPolicy' method to use a 'scroll layout'
+ * if method exists (available as of jdk1.4)
+ *
*/
public ChainsawTabbedPane() {
super();
- }
- /**
- * @param tabPlacement
- */
- public ChainsawTabbedPane(int tabPlacement) {
- super(tabPlacement);
- setBorder(null);
+ try {
+ Class tabClass = JTabbedPane.class;
+ Class[] params = new Class[]{Integer.TYPE};
+
+ Method method = tabClass.getMethod("setTabLayoutPolicy", params);
+ Object[] args = new Object[]{new Integer(1)};
+ method.invoke(this, args);
+ } catch (Exception e) {
+ //ignore
+ }
}
/**
@@ -84,7 +95,8 @@
public void addANewTab(String name, JComponent component, Icon icon) {
int selectedIndex = getSelectedIndex();
super.insertTab(name, icon, component, null, 0);
- //only select the previously existing tab if there is more than one tab
+
+ //only select the previously existing tab if there is more than one tab
if (getTabCount() > 1) {
setSelectedIndex(Math.min(selectedIndex + 1, getTabCount() - 1));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org