![](/img/trans.png)
[英]How should I drag a JLabel from one JPanel in a JFrame onto a JTextField in another JPanel in the same JFrame?
[英]How to move jpanel to another jpanel in a same jframe
我有兩個JPanel
: a1
和a2
。 a11
是a1
子面板。 我想將a11
移到a2
。 這個怎么做?
嘗試這個:
a2.add(a11); // move a11 from a1 to a2
a2.revalidate(); // apply changes in a2 layout
a1.revalidate(); // apply changes in a1 layout
a2.repaint(); // repaint a2 you to be able to see the changes
a1.repaint(); // repaint a1 you to be able to see the changes
為此,您可以先從a1中刪除a11,然后將其添加到a2中。
如下,
a1.remove(a11);
a2.add(a11);
a2.repaint();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.