Jlabel1在第一个JPanel上。当单击Jlabel时,我想显示一个CounterMeasurePanel Jpanel(在Jpanels之间切换)。我可以在Jlabel1上使用2个Jpanels和一个鼠标单击事件来实现此目的吗?
jLabe11.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
//super.mouseClicked(e);
if(e.getButton()==MouseEvent.BUTTON1){
countermeasure_box.removeAll();
countermeasure_box.add(createCountermeasure(CounterMeasure));
CounterMeasurePanel.add(countermeasure_box);
CounterMeasurePanel.revalidate();
CounterMeasurePanel.repaint();
CounterMeasurePanel.setRequestFocusEnabled(true);
}
}
});
box.add(jLabe11);