单击 JFrame 内的 JPanel
所以我有一个JFrame
,其中有一堆JPanel
,称为venPanel
。当我单击 venPanel
时,我希望 JFrame
在布局的东部添加一个新的 JPanel
(因为 JFrame< /code> 使用边框布局)。如何在我的
venPanel
类中实现此目的?目前,venPanel
的 mouseClick
操作监听器实现为:
@Override
public void mouseClicked(MouseEvent arg0) {
try {
GUIVenDetails vendetail = new GUIVenDetails(ven);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
其中 GUIVenDetails
是我想要添加到的 JPanel
JFrame
的东边.. 我希望问题很清楚..
So I have a JFrame
, in which it has a bunch of JPanel
which is called venPanel
. When I click on a venPanel
I want the JFrame
to add a new JPanel
to the east of the layout (because the JFrame
uses the border layout). How can I achieve this in my venPanel
class? Currently the mouseClick
action listener for the venPanel
is implemented as:
@Override
public void mouseClicked(MouseEvent arg0) {
try {
GUIVenDetails vendetail = new GUIVenDetails(ven);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Where GUIVenDetails
is the JPanel
I wanted to add to the east of the JFrame
..
I hope the question is clear..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
或者,您可以将
JPanel
添加到使用CardLayout
的 EAST,然后通过调用CardLayout
在该位置交换JPanel
代码>方法。Or you could add a
JPanel
to the EAST that uses aCardLayout
and then swapJPanels
in that spot by calling theCardLayout
methods.像这样的东西:
Something like: