当我创建该组件的MouseListener时,我想调用该组件本身
错误:封闭范围中定义的局部变量i必须是final或 有效地最终
我需要这样的东西:getParent.setBorder(lb)(但它调用了 父容器而不是组件)
LineBorder lB = new LineBorder(Color.BLUE, 2);
for (int i = 0; i < panelHolder.length; i++)
{
panelHolder[i] = new JPanel();
panelHolder[i].setLayout(new BorderLayout());
add(panelHolder[i]);
panelHolder[i].addMouseListener(new MouseAdapter()
{
@Override
public void mouseEntered(MouseEvent e)
{
panelHolder[i].setBorder(lB);
}
});
}