-
Bug
-
Resolution: Fixed
-
P2
-
1.1.5
-
swing0.7
-
generic
-
solaris_2.5
The SwingSet demo's InternalFrame tab works great in terms of selecting the correct JInternalFrame when
one clicks the mouse inside it.
I modified the InternalWindowPanel.java file -
1. In the LayeredView class I added a JButton. Compiled
the file and tried the InternalFrame demo tab. Now the JInternalFrame selection does not work when
I click on the JButton.
2. I replaced the JButton with JLabel ... compiled...ran the demo. It works again.
3. Then I added mouseListener to the JLabel...compiled...ran the demo. It stopped
working again.
Hmmm.... look like to me that if the JInternalFrame relies on getting the old (JDK1.0.2) mousePressed
event delivered to it to implement setSelected() behaviour.
Here is the code change I made to SwingSet/InternalWindowPanel.java -
//...
//...
class LayeredView extends JComponent {
Color pColor;
int myLayer;
public LayeredView(int layer) {
int g = 255 - Math.abs(layer % 255);
pColor = new Color(0,g,0);
myLayer = layer;
setLayout(new FlowLayout(FlowLayout.CENTER));
JLabel jl = new JLabel("Layer "+myLayer);
add(jl);
// If the next line is uncommented the setSelected() behaviour breaks.
// jl.addMouseListener(new java.awt.event.MouseAdapter(){});
}
/* Comment out
public void paint(Graphics g) {
g.setColor(pColor);
g.fillRect(0, 0, getWidth(), getHeight());
if(Math.abs(myLayer % 255) < 125)
g.setColor(Color.black);
else
g.setColor(Color.white);
g.drawString("Layer "+myLayer, (getWidth() / 3), (getHeight() / 2));
}
*/
}
one clicks the mouse inside it.
I modified the InternalWindowPanel.java file -
1. In the LayeredView class I added a JButton. Compiled
the file and tried the InternalFrame demo tab. Now the JInternalFrame selection does not work when
I click on the JButton.
2. I replaced the JButton with JLabel ... compiled...ran the demo. It works again.
3. Then I added mouseListener to the JLabel...compiled...ran the demo. It stopped
working again.
Hmmm.... look like to me that if the JInternalFrame relies on getting the old (JDK1.0.2) mousePressed
event delivered to it to implement setSelected() behaviour.
Here is the code change I made to SwingSet/InternalWindowPanel.java -
//...
//...
class LayeredView extends JComponent {
Color pColor;
int myLayer;
public LayeredView(int layer) {
int g = 255 - Math.abs(layer % 255);
pColor = new Color(0,g,0);
myLayer = layer;
setLayout(new FlowLayout(FlowLayout.CENTER));
JLabel jl = new JLabel("Layer "+myLayer);
add(jl);
// If the next line is uncommented the setSelected() behaviour breaks.
// jl.addMouseListener(new java.awt.event.MouseAdapter(){});
}
/* Comment out
public void paint(Graphics g) {
g.setColor(pColor);
g.fillRect(0, 0, getWidth(), getHeight());
if(Math.abs(myLayer % 255) < 125)
g.setColor(Color.black);
else
g.setColor(Color.white);
g.drawString("Layer "+myLayer, (getWidth() / 3), (getHeight() / 2));
}
*/
}