如何通过Jlabel从一个jpanel到另一个jpanel添加链接?

时间:2018-09-16 13:40:35

标签: jpanel jlabel

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);

0 个答案:

没有答案