简体   繁体   English

把一个组件的JFrame或通过的JLabel NetBeans中创建

[英]Add a component into Jframe or JLabel created by Netbeans

I'm using Netbeans. 我正在使用Netbeans。

I use Netbeans to create a Jframe and drag and drop a JLabel to Jframe. 我使用Netbeans创建Jframe,并将JLabel拖放到Jframe。

I want to add a JLinkButton (I use zfqjava JLinkbutoon) to Jframe and to JLable by using code(but not drap and drop) but it doesn't work. 我想通过使用代码(但不能拖放)将JLinkBut​​ton(我使用zfqjava JLinkbutoon)添加到Jframe和JLable,但是它不起作用。

Here is my code to add JLinkButton to JFrame 这是我的代码,将JLinkBut​​ton添加到JFrame

 this.getContentPane().add(linkButton);

and here is my code to add JLinkButton to JLabel 这是我的代码,将JLinkBut​​ton添加到JLabel

 lblbackground.add(linkButton);

You can't add the same JLinkButton both places. 您不能在两个地方都添加相同的JLinkBut​​ton。 It will only appear in the last place you add it. 它只会出现在您添加它的最后一个位置。 Instead create to instances of it, one for each place you want to put it. 而是为其创建实例,为要放置它的每个位置创建一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM