-
Bug
-
Resolution: Fixed
-
P3
-
1.1, 1.2.0
-
kestrel
-
generic
-
generic, solaris_10
The following bug shows that findComponentAt() is not returning the
correct component for JTabbedPane.
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Color;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import javax.swing.JPanel;
public class FolderTest extends JFrame {
public FolderTest() {
super("Folder Test");
}
public static void main(String args[]) {
FolderTest test = new FolderTest();
test.setSize(new Dimension(200, 200));
test.addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
}
);
JTabbedPane tabbedpane = new JTabbedPane();
test.setContentPane(tabbedpane);
JPanel panel1 = new JPanel();
panel1.setName("Panel 1");
panel1.setLayout(new BorderLayout());
tabbedpane.add(panel1);
JPanel subPanel = new JPanel();
subPanel.setName("Sub-Panel");
subPanel.setBackground(Color.green);
panel1.add(subPanel); // add sub panel to 1st tab
JPanel panel2 = new JPanel();
panel2.setName("Panel 2");
tabbedpane.add(panel2);
tabbedpane.setSelectedIndex(1); // display 2nd tab
test.setVisible(true);
// incorrectly finds sub panel (currently hidden in panel 1)...should return
// panel 2
System.out.println(tabbedpane.findComponentAt(50,50).getName());
}
}
correct component for JTabbedPane.
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Color;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import javax.swing.JPanel;
public class FolderTest extends JFrame {
public FolderTest() {
super("Folder Test");
}
public static void main(String args[]) {
FolderTest test = new FolderTest();
test.setSize(new Dimension(200, 200));
test.addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
}
);
JTabbedPane tabbedpane = new JTabbedPane();
test.setContentPane(tabbedpane);
JPanel panel1 = new JPanel();
panel1.setName("Panel 1");
panel1.setLayout(new BorderLayout());
tabbedpane.add(panel1);
JPanel subPanel = new JPanel();
subPanel.setName("Sub-Panel");
subPanel.setBackground(Color.green);
panel1.add(subPanel); // add sub panel to 1st tab
JPanel panel2 = new JPanel();
panel2.setName("Panel 2");
tabbedpane.add(panel2);
tabbedpane.setSelectedIndex(1); // display 2nd tab
test.setVisible(true);
// incorrectly finds sub panel (currently hidden in panel 1)...should return
// panel 2
System.out.println(tabbedpane.findComponentAt(50,50).getName());
}
}
- relates to
-
JDK-4146810 SwingUtilities.getDeepestComponentAt(...) won't work correctly with JTabbedPanes
-
- Closed
-
-
JDK-4212109 SwingUtilities.getDeepestComponentAt() not working for JTabbedPane
-
- Resolved
-