简体   繁体   English

NetBeans:如何选择驻留在JFrame中的JLabel?

[英]NetBeans: How to select JLabel that resides inside JFrame?

I developed a small desktop application in Java. 我用Java开发了一个小型桌面应用程序。 At some position in my UI I drag and drop a JLabel from Palette to JFrame . 在UI的某个位置,我将JLabel从Palette拖放到JFrame Later-on i remove its text by right click -> Edit Text. 稍后,我可以通过右键单击->编辑文本来删除其文本。 I did this because i am populating this label dynamically using setText() method. 我这样做是因为我正在使用setText()方法动态填充此标签。 Now i need to reposition this Label, for this i first have to select that label and then drag n drop it to new location. 现在,我需要重新定位此标签,为此,我首先必须选择该标签,然后将其拖放到新位置。 But i am unable to do so because there is no text in that label and hence its not visible :( Is there any way through which i select this label? 但是我无法这样做,因为该标签中没有文本,因此它是不可见的:(我可以通过什么方式选择此标签?

The easiest way is add a few spaces to a label instead of an empty string. 最简单的方法是在标签上添加一些空格而不是空字符串。 You may also put a label inside a panel with layout like Flow or Grid (where you can set margin) and drag the panel instead. 您也可以在带有“流”或“网格”(可在其中设置边距)布局的面板中放置标签,然后拖动面板。 If you're using layout like Free Design, Absolute or Null, you may also manually rescale the label (selecting it through Inspector view). 如果您使用的是Free Design,Absolute或Null之类的布局,则还可以手动重新缩放标签(通过“检查器”视图选择它)。

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

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